开发者

iPhone UINavigationController : Animate only part of the view

开发者 https://www.devze.com 2023-02-08 13:44 出处:网络
I have a UINavigationController that contains (from top to bottom) a UINavigationBar, a UIImageView and a UITableView. Every view I will push开发者_运维技巧 in the stack contains the same UIImageView

I have a UINavigationController that contains (from top to bottom) a UINavigationBar, a UIImageView and a UITableView. Every view I will push开发者_运维技巧 in the stack contains the same UIImageView at the same place (this is a logo).

I would like the logo to stay just below the UINavigationBar, with no animation when I push/pop views. Is it possible ?

Thanks


The only way I can think to achieve this would be to add the logo image view directly to the main window in your app delegate. Position it so that it will appear directly below the navigation bar. Then you'll have to set the background color of your view controller's view to clear and ensure that the opaque property is set to NO. Size your view and set the autoresizing mask so that it will be anchored to the bottom of the screen (or to the top of a tab bar or bottom toolbar).

Basically, you need to set up your view controller's view in such a way that there is a portion of the top of the view that is completely transparent. If this is the case, then the logo image view you added directly to the main window will always be visible. When pushing or popping between view controllers using your navigation controller, just ensure that every view controller's view is similarly setup to be transparent at the top right where your logo image view appears. Even if the navigation controller animates the transition, the transparency at the top of your views should only show the opaque portions of your views being animated, along with the navigation bar and its subviews.

Hope that makes sense.

UPDATE: Per Noah Witherspoon's comment, a better approach would probably be just to add your image logo view as a subview of the navigation controller's view. You'll still have to size your view controllers' views so that their contents aren't obscured by your logo image view, but this approach overall is a lot cleaner.

0

精彩评论

暂无评论...
验证码 换一张
取 消