Home » IOS » The properties and usage of UIday0603:UIImageView

The properties and usage of UIday0603:UIImageView

UIImageView with attribute




Image / /
map set
AnimationImages / group dynamic picture
set
AnimationDuration / / set the play a dynamic picture of the time of the
group
AnimationRepeatCount / / set number of repeat

StartAnimating / / to
animation

stopAnimating / / end animation


UIImageView is equivalent to a frame that can hold one or a set of pictures. UIImage is the object of the picture,


AppDelegate.m


- (BOOL), application: (UIApplication *), application, didFinishLaunchingWithOptions: (NSDictionary *), launchOptions {
Self.window = [[UIWindow, alloc], initWithFrame:[[UIScreen, mainScreen], bounds]];
Override point for customization after application / / launch.
Self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
RootViewController * rootVC = [[RootViewController alloc]init];
Self.window.rootViewController = rootVC;
Return YES;
}


RootViewController.m


#import "RootViewController.h""
@interface, RootViewController ()
@property (nonatomic, strong) RootView * rv;
@end
@implementation RootViewController
- - (void) loadView{
Self.rv = [[RootView, alloc]initWithFrame:[UIScreen, mainScreen].bounds];
Self.view = _rv;
}
- - (void) viewDidLoad {
[super viewDidLoad];
Do any additional setup after loading / the view.
/ / set the initial background image
Self.rv.imageView.image = [UIImage, imageNamed:@, "cat_angry0000.jpg"];
/ / add eatButton click event
[self.rv.eatButton addTarget:self action:@selector (eatButtonAction:) forControlEvents:UIControlEventTouchUpInside];
/ / add knockOutButton: click event
[self.rv.knockOutButton addTarget:self action:@selector (knockOutButton:) forControlEvents:UIControlEventTouchUpInside];
}
- - (void) eatButtonAction: (UIButton *) sender{
[self p_ImageViewAnimationWithName:@, "cat_eat", "count:40 duration:0.08]";
}
- - (void) knockOutButton: (UIButton *) sender{
[self p_ImageViewAnimationWithName:@, "cat_knockout", "count:81 duration:0.08]";
}
/ / private methods: Broadcast
- - (void) p_ImageViewAnimationWithName: (NSString *), name, count: (NSInteger), count, duration: (NSTimeInterval), time{
If ([self.rv.imageView isAnimating] and [name isEqualToString:@!!] {"cat_listen")
NSMutableArray * tempArray = [NSMutableArray array];
Image stitching and image / name in an array
For (int i=0; iNSString * s = [NSString, stringWithFormat:@ "%@%04d.jpg", name, i];
UIImage * image = [UIImage imageNamed:s];
[tempArray addObject:image];
}
/ / array assignment to animationImages
Self.rv.imageView.animationImages = tempArray;
/ / play time
Self.rv.imageView.animationDuration = count * time;
/ / play times
Self.rv.imageView.animationRepeatCount = 1;
/ / Animation
[self.rv.imageView startAnimating];
}else{
NSMutableArray * tempArray = [NSMutableArray array];
Image stitching and image / name in an array
NSString * s = [NSString stringWithFormat:@ "cat_listen.jpg"];
UIImage * image = [UIImage imageNamed:s];
[tempArray addObject:image];
/ / array assignment to animationImages
Self.rv.imageView.animationImages = tempArray;
/ / play time
Self.rv.imageView.animationDuration = 1;
/ / play times
Self.rv.imageView.animationRepeatCount = 1;
/ / Animation
[self.rv.imageView startAnimating];
}
}
- - (void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
Dispose of any resources that can / be recreated.
}
@end


RootView.h


#import 
@interface RootView: UIView
@property (nonatomic, strong) UIImageView * imageView;
@property (nonatomic, strong) UIButton * eatButton;
@property (nonatomic, strong) UIButton * knockOutButton;
@end


RootView.m


#import "RootView.h""
@implementation RootView
- - (instancetype) initWithFrame: (CGRect) frame
{
Self = [super initWithFrame:frame];
If (self) {
[self p_setupViews];
}
Return self;
}
/ / layout
- - (void) p_setupViews{
Self.backgroundColor = [UIColor yellowColor];
/ / set the picture size and RootView as large as
Self.imageView = [[UIImageView alloc]initWithFrame:self.bounds];
Self.imageView.backgroundColor = [UIColor grayColor];
[self addSubview:_imageView];
/ / add eatButton
Self.eatButton = [UIButton buttonWithType:UIButtonTypeSystem];
Self.eatButton.frame = CGRectMake (50, 50, 50, 50);
Self.eatButton.backgroundColor = [UIColor blueColor];
[self addSubview:_eatButton];
/ /
Self.knockOutButton = [UIButton buttonWithType:UIButtonTypeSystem];
Self.knockOutButton.frame = CGRectMake (100, 150, 180, 180);
Self.knockOutButton.backgroundColor = [UIColor clearColor];
[self addSubview:_knockOutButton];
}
@end






copyright notice: This article is original article for blogger. Without permission from blogger,.

must not be reprinted

Latest