这就是我在 UIViewController 中使用 UIView 并在 UIViewController 中添加 UIImageView 和 UITextView 作为 UIView 的子视图的方式没有显示 UITextview 的代码,因为您没有在问题中询问它。
- (void)viewDidLoad
{
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:baseView];
[baseView release];
// Displays UIImageView
UIImageView* ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 300, 235)];
self.view.backgroundColor = [UIColor brownColor];
// load all the frames of our animation
ImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1a.png"],
[UIImage imageNamed:@"1b.png"],
nil];
// all frames will execute in 25 seconds
ImageView.animationDuration = 25;
// start animating
[ImageView startAnimating];
ImageView.layer.borderWidth = 2;
ImageView.layer.borderColor = [[UIColor whiteColor]CGColor];
[ImageView.layer setMasksToBounds:YES];
[ImageView.layer setCornerRadius:15.0f];
[baseView addSubview:ImageView];
}
希望它可以帮助你。