iOS-UIImageView的总结
生活随笔
收集整理的這篇文章主要介紹了
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语言,获得堆栈增长方向的一种方法