iOS開發筆記1 -UINavigationController
歡迎加QQ羣討論:157672725
博客地址:http://catchzeng.leanote.com/
開發iOS已有一段時間,但是發覺自己掌握的東西很凌亂,所以決定以博客的形式記錄自己所學所看。希望讀者指出我的錯誤和提供寶貴意見,如需聯繫請發郵件到[email protected],謝謝!
本期筆記主要內容
1.自定義導航欄
2.右滑返回
3.自定義各種Push動畫的實現
UINavigationController
UINavigationController是比較常用的視圖控制器,以下是我在項目中遇過的問題
1.自定義導航欄
自定義導航欄有兩種思路,一種是修改UINavigationBar的屬性,另一種是使用自定義的View來替換UINavigationBar
1.1使用修改UINavigationBar的屬性方式
setTranslucent如果不設置爲NO,則通過setBarTintColor設置的顏色會是半透明的
setShadowImage:[[UIImage alloc] init] 是爲了去除底部的黑線
[[UINavigationBar appearance] setBarTintColor:kColorNavBarTint];
if ([[UINavigationBar appearance] respondsToSelector:@selector(setTranslucent:)]) {
[[UINavigationBar appearance] setTranslucent:NO];
}
[[UINavigationBar appearance] setTintColor:kColorNavBarText];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
1.2使用自定義的View來替換UINavigationBar的方式
這裏我推薦使用https://github.com/singro/SCNavigation
2.右滑返回
ios7以上其實已經自帶了該功能,如果需要兼容ios6版本的朋友我推薦使用https://github.com/singro/SCNavigation ,還有巧哥的https://github.com/Coneboy-k/KKNavigationController
3..自定義push動畫
iOS其實自帶了push動畫,但是並不一定適合每個項目的需求,由於項目需要我寫了一個category來實現各種push動畫的效果。查看效果
github項目地址:https://github.com/catchZeng/UINavigationController-PushAnimation