// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
// single image // x, y, width, height
UIImageView *singleImage = [[UIImageView alloc] initWithFrame:CGRectMake(100, 125, 150, 130)];
singleImage.image = [UIImage imageNamed:@"1.png"];
singleImage.contentMode = UIViewContentModeBottomLeft; // 置於 frame 的左下角
singleImage.alpha = 0.5f; // 透明度
[self.view addSubview:singleImage];
-----------------------------------------------------------------------------------------------------
// dynamic images
NSArray * imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
[UIImage imageNamed:@"5.png"],
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"7.png"],
[UIImage imageNamed:@"8.png"],
[UIImage imageNamed:@"9.png"],
[UIImage imageNamed:@"10.png"],
[UIImage imageNamed:@"11.png"],
[UIImage imageNamed:@"12.png"],
nil];
// x, y, width, height
UIImageView *dynamicImages = [[UIImageView alloc] initWithFrame:CGRectMake(100, 125, 150, 130)];
dynamicImages.animationImages = imageArray;
dynamicImages.animationDuration = 1.0f;
dynamicImages.contentMode = UIViewContentModeBottomLeft; // 置於 frame 的左下角
[self.view addSubview:dynamicImages];
[dynamicImages startAnimating];
}
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。