本文介绍了在 UIPageViewController 的 UIPageControl 中增加指示器的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在UIPageViewController中增加指示器的大小?

Is it possible to Increase the size of the indicator in UIPageViewController?

我有这个:

我的要求是:

推荐答案

缩放页面控件将缩放点,但也会缩放它们之间的间距.

Scaling the page control will scale the dots, but will also scale the spacing in between them.

pageControl.transform = CGAffineTransform(scaleX: 2, y: 2)

如果要保持点之间的间距相同,则需要单独转换点:

If you want to keep the same spacing between dots, you'll need to transform the dots individually:

pageControl.subviews.forEach {
    $0.transform = CGAffineTransform(scaleX: 2, y: 2)
}

但是,如果您在 viewDidLoad 中执行此操作,则在视图出现时转换已重置,因此您应该在 viewDidLayoutSubviews...

However, if you do this in viewDidLoad, the transform has been reset by the time the view appears, so you should do this in viewDidLayoutSubviews

override func viewDidLayoutSubviews() {
    pageControl.subviews.forEach {
        $0.transform = CGAffineTransform(scaleX: 2, y: 2)
    }
}

这篇关于在 UIPageViewController 的 UIPageControl 中增加指示器的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:59