UIImageView

2015-09-18  本文已影响97人  lvvl

contentMode属性

语法点

imageView.frame.size = imageView.image.size;
CGRect tempFrame = imageView.frame;
tempFrame.size = imageView.image.size;
imageView.frame = tempFrame;

initWithImage:方法

修改frame的3种方式

imageView.frame = CGRectMake(100, 100, 200, 200);
CGRect tempFrame = imageView.frame;
tempFrame.origin.x = 100;
tempFrame.origin.y = 100;
tempFrame.size.width = 200;
tempFrame.size.height = 200;
imageView.frame = tempFrame;
imageView.frame = (CGRect){{100, 100}, {200, 200}};

帧动画(UIImageView特有的动画方式)

// 0. 是否正在动画
[self.tom isAnimating];
// 1. 设置图片的数组
[self.tom setAnimationImages:arrayM];
// 2. 设置动画时长,默认每秒播放30张图片
[self.tom setAnimationDuration:arrayM.count * 0.075];
// 3. 设置动画重复次数,默认为0,无限循环
[self.tom setAnimationRepeatCount:1];
// 4. 开始动画
[self.tom startAnimating];
// 5. 动画播放完成后,清空动画数组
[self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.tom.animationDuration];

上一篇 下一篇

猜你喜欢

热点阅读