【问题标题】:How to make pagecontrol with text displaying in each view如何使页面控件在每个视图中显示文本
【发布时间】:2017-05-27 15:34:42
【问题描述】:

如何在每个视图上使用 UILabel 制作页面控件以显示文本?我在 viecontroller 中有滚动视图和一个用于显示文本的标签。我需要创建尽可能多的视图来显示不同的文本。

【问题讨论】:

  • 您想用UILabels 替换UIPageControl 的点吗?

标签: ios swift xcode uipageviewcontroller uipagecontrol


【解决方案1】:

您可以使用带有分页启用功能的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);
}

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-04
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多