2017-10-04 2 views
0

Je suis en train d'accomplir ce qui suit sur iOS: personnalisé UINavigationBar iOS avec deux UITextViewsur mesure UINavigationBar iOS avec UITextView

Bellow vous pouvez voir la même chose sur Android.

Est-ce possible avec UINavigationBar? Comment puis-je faire cela?

J'ai essayé d'utiliser un UIBarButtonItem avec un UIView personnalisé mais il semble que sa taille soit limitée et que je ne puisse pas accomplir ce que je veux.

Android Example

+0

Qu'avez-vous essayé jusqu'à présent? – picciano

Répondre

0

Quelque chose comme ça. Ce ne sera pas possible avec les storyboards et probablement ne serait même pas essayer.

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

Vous aurez juste besoin d'ajouter le reste des objets –