创建垂直 UIPageControl

发布于 2024-10-16 11:34:00 字数 106 浏览 5 评论 0原文

有人知道如何创建垂直 UIPageControl 吗?我有一个启用分页的 UIScrollView,我想让 UIPageControl 坐在侧面并垂直而不是水平显示。

先感谢您...

Anyone have an idea how to create a vertical UIPageControl? I have a UIScrollView with pagination enabled and I would like to have the UIPageControl sit on the side and appear vertically instead of horizontally.

Thank you in advance...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

你好,陌生人 2024-10-23 11:34:00

您可以对 UIPageControl 应用旋转变换。

pageControl.transform = CGAffineTransformMakeRotation(M_PI_2);

斯威夫特 3.0

let angle = CGFloat(M_PI_2)
pageControl.transform = CGAffineTransform(rotationAngle: angle)

斯威夫特 4.0

let angle = CGFloat.pi/2
    pageControl.transform = CGAffineTransform(rotationAngle: angle)

You can apply a rotation transformation to the UIPageControl.

pageControl.transform = CGAffineTransformMakeRotation(M_PI_2);

Swift 3.0

let angle = CGFloat(M_PI_2)
pageControl.transform = CGAffineTransform(rotationAngle: angle)

Swift 4.0

let angle = CGFloat.pi/2
    pageControl.transform = CGAffineTransform(rotationAngle: angle)
梦旅人picnic 2024-10-23 11:34:00

Swift 3.1 更新

pageControl.transform = pageControl.transform.rotated(by: .pi/2)

Update for Swift 3.1

pageControl.transform = pageControl.transform.rotated(by: .pi/2)
私藏温柔 2024-10-23 11:34:00

iOS 16 及更高版本支持使用 方向

pageControl.direction = .topToBottom

iOS 16 and later versions support the use of the direction

pageControl.direction = .topToBottom
ㄟ。诗瑗 2024-10-23 11:34:00

您可以使用启用分页和垂直滚动的 UICollectionView。这会自动处理垂直分页。

You can use UICollectionView with paging enabled and vertical scroll. This handles the vertical pagination automatically.

盛装女皇 2024-10-23 11:34:00

页面控件有子视图,必须旋转子视图才能形成垂直点

//create page control

    private let pageControl: UIPageControl = {
    let pageControl = UIPageControl()
    pageControl.numberOfPages = 3
    return pageControl
}()

//add page control as a subview to container UIView

override func viewDidLoad() {
     pageViewContainer.addSubview(pageControl)
}

//rotate it vertically

override func viewWillLayoutSubviews() {
    pageControl.frame = pageViewContainer.bounds
    pageControl.subviews.last?.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
    pageControl.subviews.first?.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
}

page control has subviews, which must be rotated to make vertical dots

//create page control

    private let pageControl: UIPageControl = {
    let pageControl = UIPageControl()
    pageControl.numberOfPages = 3
    return pageControl
}()

//add page control as a subview to container UIView

override func viewDidLoad() {
     pageViewContainer.addSubview(pageControl)
}

//rotate it vertically

override func viewWillLayoutSubviews() {
    pageControl.frame = pageViewContainer.bounds
    pageControl.subviews.last?.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
    pageControl.subviews.first?.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文