contentMode屬性
- 帶有scale單詞的:圖片有可能會(huì)拉伸
- UIViewContentModeScaleToFill
- 將圖片拉伸至填充整個(gè)imageView
- 圖片顯示的尺寸跟imageView的尺寸是一樣的
- 帶有aspect單詞的:
保持圖片原來(lái)的寬高比
- UIViewContentModeScaleAspectFit
-
一定能
看到圖片的全部(縮放后,只要能看到原圖的全部就行)
進(jìn)行等比例縮放
- 縮放后的圖片的中心點(diǎn)置于控件中心點(diǎn)處
- UIViewContentModeScaleAspectFill(
通常用這種方式來(lái)鋪滿整個(gè)控件,又保持原有圖片寬高比
)
-
有可能
看不到圖片的全部(縮放后,只要能覆蓋住控件的全部就行,)
進(jìn)行等比例縮放
- 縮放后的圖片的中心點(diǎn)置于控件中心點(diǎn)處
- 沒(méi)有scale單詞的:圖片絕對(duì)不會(huì)被拉伸泼菌,保持圖片的原尺寸
- UIViewContentModeCenter
- UIViewContentModeTop
- UIViewContentModeBottom
- UIViewContentModeLeft
- UIViewContentModeRight
- UIViewContentModeTopLeft
- UIViewContentModeTopRight
- UIViewContentModeBottomLeft
- UIViewContentModeBottomRight
語(yǔ)法點(diǎn)
- 不能直接修改:OC對(duì)象的結(jié)構(gòu)體屬性的成員
- 下面的寫(xiě)法是錯(cuò)誤的
imageView.frame.size = imageView.image.size;
CGRect tempFrame = imageView.frame;
tempFrame.size = imageView.image.size;
imageView.frame = tempFrame;
initWithImage:方法
- 利用這個(gè)方法創(chuàng)建出來(lái)的imageView的尺寸和傳入的圖片尺寸一樣
修改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}};
幀動(dòng)畫(huà)(UIImageView特有的動(dòng)畫(huà)方式)
// 0. 是否正在動(dòng)畫(huà)
[self.tom isAnimating];
// 1. 設(shè)置圖片的數(shù)組
[self.tom setAnimationImages:arrayM];
// 2. 設(shè)置動(dòng)畫(huà)時(shí)長(zhǎng),默認(rèn)每秒播放30張圖片
[self.tom setAnimationDuration:arrayM.count * 0.075];
// 3. 設(shè)置動(dòng)畫(huà)重復(fù)次數(shù),默認(rèn)為0攀芯,無(wú)限循環(huán)
[self.tom setAnimationRepeatCount:1];
// 4. 開(kāi)始動(dòng)畫(huà)
[self.tom startAnimating];
// 5. 動(dòng)畫(huà)播放完成后芳悲,清空動(dòng)畫(huà)數(shù)組
[self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.tom.animationDuration];
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者