【发布时间】:2017-05-27 15:34:42
【问题描述】:
如何在每个视图上使用 UILabel 制作页面控件以显示文本?我在 viecontroller 中有滚动视图和一个用于显示文本的标签。我需要创建尽可能多的视图来显示不同的文本。
【问题讨论】:
-
您想用
UILabels 替换UIPageControl的点吗?
标签: ios swift xcode uipageviewcontroller uipagecontrol
如何在每个视图上使用 UILabel 制作页面控件以显示文本?我在 viecontroller 中有滚动视图和一个用于显示文本的标签。我需要创建尽可能多的视图来显示不同的文本。
【问题讨论】:
UILabels 替换UIPageControl 的点吗?
标签: ios swift xcode uipageviewcontroller uipagecontrol
您可以使用带有分页启用功能的collectionView 来代替使用scrollView .. scrollview 在collectionView 重用单元格的地方占用大量内存.. 使用集合水平流布局并制作单元格大小
// 目标-c
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(CGRectGetWidth(collectionView.frame), (CGRectGetHeight(collectionView.frame)));
}
//Swift
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSize(width: screenWidth, height: screenWidth);
}
谢谢
【讨论】: