iOS開發UI篇--使用UICollectionView實現一個傾斜列表效果
一、案例演示
本案例演示的是每個cell都有一點傾斜角度的效果,如下圖所示:

1.gif
二、知識儲備
2.1、如何讓CELL傾斜
其實 layoutAttributes 已經為我們提供了 transform 屬性,我們可以使用這個屬性來實現旋轉。
關鍵程式碼示例:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{ NSArray *attributes = [super layoutAttributesForElementsInRect:rect]; for (UICollectionViewLayoutAttributes *attr in attributes ) { CGFloat degrees = M_PI * (-14.0f/180.0f); attr.transform = CGAffineTransformMakeRotation(degrees); } return attributes; }
三、Demo下載地址
Demo下載地址:這是一個我的iOS交流群:624212887,群檔案自行下載,不管你是小白還是大牛熱烈歡迎進群 ,分享面試經驗,討論技術, 大家一起交流學習成長!希望幫助開發者少走彎路。——點選: ofollow,noindex">加入
如果覺得對你還有些用,就關注小編+喜歡這一篇文章。你的支援是我繼續的動力。
下篇文章預告: YXFilmSelectView(一個酷炫的電影選票View)
文章來源於網路,如有侵權,請聯絡小編刪除。