2017-10-04 59 views
0

我試圖完成在iOS以下自定義UINavigationBar的iOS設備上: 定製UINavigationBar的iOS版有兩個UITextView的與UITextView的

婁你可以看到在Android上是相同的。

這可能與UINavigationBar? 我該怎麼做?

我嘗試使用UIBarButtonItem與自定義UIView,但它似乎是有限的大小,所以不能完成我想要的。

Android Example

+0

你到目前爲止嘗試過什麼? – picciano

回答

0

這樣的事情。故事板不可能,甚至可能不會嘗試。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

    window = UIWindow(frame: UIScreen.main.bounds) 
    window?.makeKeyAndVisible() 

    let layout = UICollectionViewFlowLayout() 


    UINavigationBar.appearance().barTintColor = UIColor.yellow 


    UINavigationBar.appearance().shadowImage = UIImage() 
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default) 

    application.statusBarStyle = .lightContent 

    let textViewOne = UITextView() 
    textViewOne.text = "1000" 


    window?.addSubview(textViewOne) 
    //top constraint 

    window?.addConstraintsWithFormat("H:[v0(100)]-16-|", views: textViewOne) 

    window?.addConstraintsWithFormat("V:|-16-[v0(24)]", views: textViewOne) 
    return true 
} 



extension UIView { 
    func addConstraintsWithFormat(_ format: String, views: UIView...) { 
     var viewsDictionary = [String: UIView]() 
     for (index, view) in views.enumerated() { 
      let key = "v\(index)" 
      view.translatesAutoresizingMaskIntoConstraints = false 
      viewsDictionary[key] = view 
     } 

     addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDictionary)) 
    } 
} 
+0

您只需添加其餘的對象 –