当前位置:
首页 >
iOS-UIImageView的总结
发布时间:2025/3/21
38
豆豆
生活随笔
收集整理的这篇文章主要介绍了
iOS-UIImageView的总结
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
1.UIImageView的使用模式contentMode
contentMode有以下几种:
- 带有scale的:图片有可能会拉伸
- 没有scale单词的:图片不会被拉伸,保持图片的原尺寸, 只是位置变化
- UIViewContentModeCenter - UIViewContentModeTop - UIViewContentModeBottom - UIViewContentModeLeft - UIViewContentModeRight - UIViewContentModeTopLeft - UIViewContentModeTopRight - UIViewContentModeBottomLeft - UIViewContentModeBottomRight
2.其他属性
- 裁剪超出imageView边框的部分
连续播放动画
可以使用UIImageVIew连续播放动画,要用到这几个属性和方法:
@property(nonatomic,copy) NSArray *animationImages; @property(nonatomic) NSTimeInterval animationDuration; // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps) @property(nonatomic) NSInteger animationRepeatCount; // 0 means infinite (default is 0)- (void)startAnimating;举例:
_imageView.animationImages = imagesArray;_imageView.animationDuration = number * 0.08;_imageView.animationRepeatCount = [prefix isEqualToString:@"stand"]?0:1;// 设置图片[_imageView startAnimating];[_imageView performSelector:@selector(StandFunc:) withObject:nil afterDelay:_imageView.animationDuration inModes:nil];把需要播放的图片的数组传递给animationImages,然后设置动画时间animationDuration和重复次数animationRepeatCount,就可以开始动画了。最后还可以设置动画结束后的行为 performSelector:afterDelay: inModes方法
3.加入音频的方法
1.导入头文件
objc #import <AVFoundation/AVFoundation.h>
2.设置播放对象
3.给出音频路径,并播放
NSURL *url = [[NSBundle mainBundle] URLForResource:@"dazhao" withExtension:@"mp3"]; _player = [AVPlayer playerWithURL:url]; [_player play];4.效果展示
转载于:https://www.cnblogs.com/66it/articles/4603560.html
总结
以上是生活随笔为你收集整理的iOS-UIImageView的总结的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: MySQL中用decimal的原因
- 下一篇: C语言,获得堆栈增长方向的一种方法