2017-10-04 83 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

您只需添加其余的对象 –