Pag*_*gly 3 calayer uiimageview ios layoutsubviews
在我的UICollectionViewCell类中,我写了这个:
- (void)layoutSubviews {
[super layoutSubviews];
self.myImageView.layer.cornerRadius = CGRectGetHeight(self.myImageView.frame) / 2;
self.myImageView.layer.masksToBounds = YES;
}
Run Code Online (Sandbox Code Playgroud)
但这在所有情况下都无法正常工作,它看起来像这样:
我在尝试在TableView Cell中获取collectionView时遇到了类似的问题.
如果要更改单元格的模型,则应告诉单元格重新计算其布局,以便单元格更改其大小和调用layoutIfNeeded.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
UICollectionViewCell*cell = ...
// Do your stuff here to configure the cell
// Tell the cell to redraw its contentView
[cell layoutIfNeeded];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
748 次 |
| 最近记录: |