[iOS微博項目,[iOS博項目

來源:互聯網
上載者:User

[iOS微博項目,[iOS博項目
A.導覽列兩側文字按鈕1.需求:所有導覽列兩側的文字式按鈕統一樣式普通樣式:橙色高亮樣式:紅色不可用樣式:亮灰陰影:不使用字型大小:15 github: https://github.com/hellovoidworld/HVWWeibo 2.實現效果預設樣式: 1 /** 類初始化的時候調用 */ 2 + (void)initialize { 3 // 初始化導覽列樣式 4 [self initNavigationBarTheme]; 5 6 // 初始化導覽列item樣式 7 [self initBarButtonItemTheme]; 8 } 9 10 /** 統一設定導覽列item的樣式 11 * 因為是通過主題appearence統一修改所有NavivationBar的樣式,可以使用類方法12 */13 + (void) initBarButtonItemTheme {14 // 設定導覽列,修改所有UINavigationBar的樣式15 UIBarButtonItem *appearance = [UIBarButtonItem appearance];16 17 // 設定noraml狀態下的樣式18 NSMutableDictionary *normalTextAttr = [NSMutableDictionary dictionary];19 // 字型大小20 normalTextAttr[NSFontAttributeName] = [UIFont systemFontOfSize:15];21 // 字型顏色22 normalTextAttr[NSForegroundColorAttributeName] = [UIColor orangeColor];23 // 設定為normal樣式24 [appearance setTitleTextAttributes:normalTextAttr forState:UIControlStateNormal];25 26 // 設定highlighted狀態下的樣式27 NSMutableDictionary *highlightedTextAttr = [NSMutableDictionary dictionaryWithDictionary:normalTextAttr];28 // 字型顏色29 highlightedTextAttr[NSForegroundColorAttributeName] = [UIColor redColor];30 // 設定為normal樣式31 [appearance setTitleTextAttributes:highlightedTextAttr forState:UIControlStateHighlighted];32 33 // 設定disabled狀態下的樣式34 NSMutableDictionary *disabledTextAttr = [NSMutableDictionary dictionaryWithDictionary:normalTextAttr];35 // 字型顏色36 disabledTextAttr[NSForegroundColorAttributeName] = [UIColor lightGrayColor];37 // 設定為normal樣式38 [appearance setTitleTextAttributes:disabledTextAttr forState:UIControlStateDisabled];39 40 } B.設定導覽列樣式1.需求:

  • 統一顯示文字顏色:黑色
  • 文字陰影:禁止
  • 字型大小:20
  1 /** 統一設定導覽列樣式 */ 2 + (void) initNavigationBarTheme { 3 // 使用appearence(主題)設定,統一修改所有導覽列樣式 4 UINavigationBar *appearance = [UINavigationBar appearance]; 5 6 // 為了統一iOS6和iOS7,iOS6需要設定導覽列背景來類比iOS7的效果 7 if (!iOS7) { 8 [appearance setBackgroundImage:[UIImage imageWithNamed:@"navigationbar_background"] forBarMetrics:UIBarMetricsDefault]; 9 }10 11 // 設定屬性12 NSMutableDictionary *attr = [NSMutableDictionary dictionary];13 // 設定字型14 attr[NSForegroundColorAttributeName] = [UIColor blackColor];15 attr[NSFontAttributeName] = [UIFont systemFontOfSize:20];16 // 消去文字陰影,設定陰影位移為017 NSShadow *shadow = [[NSShadow alloc] init];18 shadow.shadowOffset = CGSizeZero;19 attr[NSShadowAttributeName] = shadow;20 21 [appearance setTitleTextAttributes:attr];22 } 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.