日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS-UIImageView的总结

發布時間:2025/3/21 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS-UIImageView的总结 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.UIImageView的使用模式contentMode

  • contentMode有以下幾種:

  • 帶有scale的:圖片有可能會拉伸
- UIViewContentModeScaleToFill- 將圖片拉伸至填充整個imageView``` - 帶有aspect單詞的:保持圖片原來的寬高比 - UIViewContentModeScaleAspectFit- 保證剛好能看到圖片的全部- UIViewContentModeScaleAspectFill- 拉伸至圖片的寬度或者高度跟imageView一樣 ```
  • 沒有scale單詞的:圖片不會被拉伸,保持圖片的原尺寸, 只是位置變化
    - UIViewContentModeCenter - UIViewContentModeTop - UIViewContentModeBottom - UIViewContentModeLeft - UIViewContentModeRight - UIViewContentModeTopLeft - UIViewContentModeTopRight - UIViewContentModeBottomLeft - UIViewContentModeBottomRight

2.其他屬性

  • 裁剪超出imageView邊框的部分
imageView.clipsToBounds = YES;

連續播放動畫

可以使用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.設置播放對象

@property (strong, nonatomic)AVPlayer *player;

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的总结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。