4

Apple says in its Documentation:

It is permissible to customize the appearance of the navigation bar using the methods and properties of the UINavigationBar class but you must never change its frame, bounds, or alpha values or modify its view hierarchy directly.

They never strictly mention that changing constraints is not allowed but I'm assuming it falls under the same criteria as of changing the frame.

I would need this for a messages app in order to achieve the translucency effect under the iMessage standard top bar. What I currently have is a UINavigationController embedded in a MSMessagesAppViewController with the topAnchor set underneath the topLayoutGuide. This prevents me from achieving the effect but places the navigation bar below the top bar accordingly. If I set the constraints to just attach to the topAnchor, the Navigation bar is hidden in the extended view. Changing the constraints of the UINavigationBar here could solve the problem.

Am I allowed to change the constraints of the UINavigationBar and if not, any other solutions for this issue? For any further information just tell me.

Christoph
  • 702
  • 6
  • 16
  • I'm looking to do something very similar to what you did. I have an MSMessagesAppViewController to which I add a UINavigationController programmatically in order to push different views onto the stack. When I expand, the Views are hidden behind the top (where it shows a picture of the person you are having a conversation with. I'm using Xamarin and tried something like this: navController.View.TopAnchor.ConstraintEqualTo(mainViewController.TopLayoutGuide.GetBottomAnchor()); – Gandalf458 Dec 02 '16 at 22:34

1 Answers1

0

I don't know how well anyone on Stack Overflow can answer this question, since it ultimately comes down to Apple's opinion/review. I've shipped apps with oversized/modified Navigation Bar and Navigation Controller frames without rejection from Apple, so I would tentatively say that this is safe to modify in your app.

I'm not sure what you're describing (as I don't know what MessagesController is), but it sounds like you have a Navigation Controller embedded inside another Navigation controller, and fixing the issue by hiding one of the bars sounds like a code smell...

JAL
  • 41,701
  • 23
  • 172
  • 300
  • MessagesController is the default ViewController for Messages extensions. If you check out one of the new Messages Apps and go to extended mode you'll know what i mean with the default bar. They are relatvily new and therefore their bahaviour is sometimes a bit unexpected. – Christoph Sep 16 '16 at 04:19
  • @Cristoph is this an iOS 10 thing? Can you provide a link to the Apple docs? – JAL Sep 16 '16 at 11:42
  • https://developer.apple.com/reference/messages/msmessagesappviewcontroller – Christoph Sep 16 '16 at 14:00
  • @Christoph, ah `MSMessagesAppViewController` is not `MessagesController` like you said in your question. – JAL Sep 16 '16 at 14:01