自定义UIPageControl的位置 [英] Customise Position of UIPageControl
本文介绍了自定义UIPageControl的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用github中的项目作为参考.
I am using project from github as a reference.
项目网址:
https://github.com/lephuocdai/iOSsample/tree/master/PageViewDemo
在这个项目中,我想在左上角显示UIPageControl.
In this project i want to show the UIPageControl at top left position .
我尝试使用CGRectMake()将pageControl的rect属性设置为某个值;但是它始终显示在底部中心
I tried setting the rect property of pageControl using CGRectMake() to some value ;But it shows always at bottom center
推荐答案
这是一种非常整洁且100%有效的方法来更改pageControl的位置
here s a very neat and 100% effective way to get to change the position of the pageControl
extension UIPageViewController {
override open func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
for subV in self.view.subviews {
if type(of: subV).description() == "UIPageControl" {
let pos = CGPoint(x: newX, y: newY)
subV.frame = CGRect(origin: pos, size: subV.frame.size)
}
}
}
}
这篇关于自定义UIPageControl的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文