在某些对象之间添加子视图

时间:2013-10-11 05:50:12

标签: objective-c addsubview

我的视图控制器中有一个滚动视图。

我正在添加子视图

UIImageView *IMG1 = [[UIImageView alloc] init];
IMG1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"IMAGE.png"]];
[self.view addSubview:IMG1];
IMG1.frame = CGRectMake(20, 20, 35, 35);

所以问题是如何在我的滚动条下添加它(在滚动条和我的视图之间)?

1 个答案:

答案 0 :(得分:1)

将此内容移至ViewDidLoad并在imageView

之后添加scrollView
-(void) viewDidLoad
{
[super viewDidLoad]

UIImageView *IMG1 = [[UIImageView alloc] init];
IMG1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"IMAGE.png"]];
[self.view addSubview:MySubImage];
IMG1.frame = CGRectMake(20, 20, 35, 35);
  [self.view sendSubviewToBack:IMG1];
//// add your scrollView and subViews 
}