iOS-UIImageView的总结
生活随笔
收集整理的這篇文章主要介紹了
iOS-UIImageView的总结
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.UIImageView的使用模式contentMode
contentMode有以下幾種:
- 帶有scale的:圖片有可能會(huì)拉伸
- 沒有scale單詞的:圖片不會(huì)被拉伸,保持圖片的原尺寸, 只是位置變化
- UIViewContentModeCenter - UIViewContentModeTop - UIViewContentModeBottom - UIViewContentModeLeft - UIViewContentModeRight - UIViewContentModeTopLeft - UIViewContentModeTopRight - UIViewContentModeBottomLeft - UIViewContentModeBottomRight
2.其他屬性
- 裁剪超出imageView邊框的部分
連續(xù)播放動(dòng)畫
可以使用UIImageVIew連續(xù)播放動(dòng)畫,要用到這幾個(gè)屬性和方法:
@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;// 設(shè)置圖片[_imageView startAnimating];[_imageView performSelector:@selector(StandFunc:) withObject:nil afterDelay:_imageView.animationDuration inModes:nil];把需要播放的圖片的數(shù)組傳遞給animationImages,然后設(shè)置動(dòng)畫時(shí)間animationDuration和重復(fù)次數(shù)animationRepeatCount,就可以開始動(dòng)畫了。最后還可以設(shè)置動(dòng)畫結(jié)束后的行為 performSelector:afterDelay: inModes方法
3.加入音頻的方法
1.導(dǎo)入頭文件
objc #import <AVFoundation/AVFoundation.h>
2.設(shè)置播放對(duì)象
3.給出音頻路徑,并播放
NSURL *url = [[NSBundle mainBundle] URLForResource:@"dazhao" withExtension:@"mp3"]; _player = [AVPlayer playerWithURL:url]; [_player play];4.效果展示
轉(zhuǎn)載于:https://www.cnblogs.com/66it/articles/4603560.html
總結(jié)
以上是生活随笔為你收集整理的iOS-UIImageView的总结的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL中用decimal的原因
- 下一篇: HTML的checkbox和radio的