1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad { [super viewDidLoad];
[self UIImageViewAnimation]; }
-(void)UIImageViewAnimation{ UIImageView *bgView = [[UIImageView alloc]initWithFrame:self.view.bounds]; bgView.image = [UIImage imageNamed:@"back2.jpg"]; [self.view addSubview:bgView]; UIImageView *birdView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 121, 96)]; birdView.image = [UIImage imageNamed:@"DOVE 1"]; NSMutableArray *mArray = [NSMutableArray array]; for (int i = 1 ; i <19; i ++) { NSString *PicName = [NSString stringWithFormat:@"DOVE %d",i]; UIImage *image = [UIImage imageNamed:PicName]; [mArray addObject:image]; } birdView.animationImages = mArray; birdView.animationDuration = 1; birdView.animationRepeatCount = 2; [birdView startAnimating]; [self.view addSubview:birdView]; }
-(void)createUIImageView{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 200, 200)]; imageView.backgroundColor = [UIColor lightGrayColor]; imageView.image = [UIImage imageNamed:@"back2.jpg"]; imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:imageView];
UIImage *image = [UIImage imageNamed:@"back2.jpg"]; NSLog(@"%f----%f",image.size.width,image.size.height); }
@end
|