gitHub上又看到个很炫的动画
UIImageView 自拉动漫 N张图纸达成很炫的动漫,
gitHub上又见到个很炫的卡通:
看了看她的代码,发掘核心动漫(正是把开关包装成一个礼物盒)其实相当轻易,正是把三个卡通的朝气蓬勃帧生机勃勃帧都截取下来放到二个数组里面,然后选用了UIImageView自带的能够播放几个image的数组的艺术。
简化过的代码几乎是那样子: - (void卡塔尔(قطرviewDidLoad { [super
viewDidLoad]; NSMutableArray *array = [NSMutableArray array];
for (int i = 0; i < 40; i ) {
UIImage *image = [UIImage imageNamed:[NSString
stringWithFormat: @"gifbutton000d",i]];
[array addObject:image];
}
self.giftImageArray = array;
self.giftImageView.animationDuration = 1.0;
self.giftImageView.animationImages = self.giftImageArray;
self.giftImageView.animationRepeatCount = 1;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer
alloc] initWithTarget:self
action:@selector(handleGiftImageViewTapped:)];
[self.giftImageView addGestureRecognizer:tapGesture];
self.giftImageView.userInteractionEnabled = YES;
self.giftImageView.image = [self.giftImageArray firstObject];
} - (void)handleGiftImageViewTapped:(UITapGestureRecognizer
*)sender {
[self.giftImageView startAnimating];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 *
NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIImage *image = [self.giftImageArray lastObject];
self.giftImageView.image = image;
}卡塔尔(英语:State of Qatar); } 效果如图:
方法就算简易,不过意义绝对的赞,不了解有未有越来越好的完结形式,但那足足是大器晚成种完结情势,值得记录一下!
自牵动漫 N张图片达成很炫的动漫, gitHub上又见到个很炫的卡通片:...
本文由金沙澳门官网-www.js333com-金沙js333com发布于金沙澳门官网计算机,转载请注明出处:gitHub上又看到个很炫的动画