UINavigationBar title label text

前端 未结 3 1729
情歌与酒
情歌与酒 2021-01-12 19:40

Is it possible to get the title text to shrink to fit in the UINavigationBar in iOS.

(for portrait iPhone app with no autolayout).

I\'m setting

3条回答
  •  孤城傲影
    2021-01-12 20:01

    Xcode 7.1 - Swift 2.0
    
    
    //Adding Title Label
            var navigationTitlelabel = UILabel(frame: CGRectMake(0, 0, 200, 21))
            navigationTitlelabel.center = CGPointMake(160, 284)
            navigationTitlelabel.textAlignment = NSTextAlignment.Center
            navigationTitlelabel.textColor  = UIColor.whiteColor()
            navigationTitlelabel.text = "WORK ORDER"
            self.navigationController!.navigationBar.topItem!.titleView = navigationTitlelabel
    

提交回复
热议问题