iPhone控件之UIImageView

- (void)viewDidLoad {

[super viewDidLoad];

UIImage *anImage = [UIImage imageNamed:@"apple.png"];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:anImage];

[[self view] addSubview:myImageView];

//scale our height and width by 50%
CGSize viewSize = myImageView.bounds.size;
viewSize.width = viewSize.width * 0.5; //make our width 50% smaller
viewSize.height = viewSize.height; //keep height the same

CGRect newFrame = CGRectMake(0,0,viewSize.width, viewSize.height);
[myImageView setFrame:newFrame];
myImageView.contentMode = UIViewContentModeScaleAspectFit;

[myImageView release];
}

UIImageView2

- (void)viewDidLoad {

[super viewDidLoad];

NSArray *arrImages = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"apple.png"],
[UIImage imageNamed:@"apple2.png"],
[UIImage imageNamed:@"apple3.png"],nil];

CGRect viewFrame = CGRectMake(0,0,200,200);
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:viewFrame];

[myImageView setAnimationImages:arrImages];

[myImageView setAnimationRepeatCount:0];
[myImageView setAnimationDuration:0.5];

[self.view addSubview:myImageView];
[myImageView startAnimating];

[arrImages release];
[myImageView release];
}



posted @ 2012-03-13 13:02  FoxBabe  阅读(201)  评论(0编辑  收藏  举报