【问题标题】:How to add a pageControl and title in the navigation bar?如何在导航栏中添加 pageControl 和标题?
【发布时间】:2017-11-07 10:53:54
【问题描述】:

如何在导航栏中添加页面控件和标题。

我需要设置为截图。 我试过导航项的titleView。 但是,我无法设置标题。

let navBarSize = navigationController!.navigationBar.bounds.size
        let origin = CGPoint(x:navBarSize.width/2,y:navBarSize.height/2)
        pageControl = UIPageControl(frame: CGRect(x: origin.x,y: origin.y,width: 10,height: 10))
        self.pageControl.currentPage = 0
        self.pageControl.tintColor = UIColor.black
        self.pageControl.pageIndicatorTintColor = UIColor.white
        self.pageControl.currentPageIndicatorTintColor = UIColor.black
        self.navigationItem.titleView = self.pageControl

【问题讨论】:

  • 发布您的代码。你试过什么?
  • 你必须用UILabelUIPageControl创建一个titleView
  • @Venkat :我已经更新了代码。

标签: ios swift uinavigationcontroller navigationbar


【解决方案1】:

正如@Alistra 所说,您需要创建一个UIView 并在其中添加一个UILabelUIPageControl,然后将UIView 设置为titleView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多