麻花豆传媒剧国,亚洲国产精品无码,欧州黄片视频免费观看,外国性生活一区二区

問(wèn)答

1080+1920的狀態(tài)欄和導(dǎo)航欄多高

提問(wèn)者:沒(méi)特點(diǎn)都2015-04-13 00:00

最佳答案

在開(kāi)始定制之前,我們先來(lái)看看iOS 7中默認(rèn)導(dǎo)航欄的外觀。通過(guò)Xcode用Single View Controller模板創(chuàng)建一個(gè)工程。然后將view controller嵌入到一個(gè)navigation controller中。如果你不想從頭開(kāi)始,那么也可以在這里下載到這個(gè)示例工程。 Xcode 5包含有iOS 6和iOS 7模擬器,我們可以在這兩個(gè)不同的模擬器版本中運(yùn)行示例程序,進(jìn)行對(duì)比,如下圖所示: vcC4tcSxs76w0dXJqzwvaDM+CjxwPtTaaU9TIDfW0KOssrvU2cq508N0aW50Q29sb3LK9NDUwLTJ6NbDtby6vcC4tcTR1cmro6y2+MrHyrnTw2JhclRpbnRDb2xvcsr00NTAtNDeuMSxs76wyauho87Sw8e/ydLU1No8Y29kZT5BcHBEZWxlZ2F0ZS5tPC9jb2RlPs7EvP7W0LXEt723qDxjb2RlPmRpZEZpbmlzaExhdW5jaGluZ1dpdGhPcHRpb25zOjwvY29kZT7A78PmzO2808jnz8K0+sLrwLTQ3rjE0dXJq6O6PC9wPgoKPHRhYmxlPgo8dGJvZHk+Cjx0cj4KPHRkIGNsYXNzPQ=="gutter"> ? 1 1 ? 1 2 [[UINavigationBar appearance] setBarTintColor:[UIColor yellowColor]]; 效果如下圖所示: \ 一般情況,我們都會(huì)使用自己的顏色,下面這個(gè)宏用來(lái)設(shè)置RGB顏色非常方便: ? 1 1 ? 1 2 #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 將上面這個(gè)宏放到AppDelegate.m文件中,然后通過(guò)這個(gè)宏來(lái)創(chuàng)建一個(gè)UIColor對(duì)象(根據(jù)指定的RGB)。如下示例: ? 1 1 ? 1 2 [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)]; 默認(rèn)情況下,導(dǎo)航欄的translucent屬性為YES。另外,系統(tǒng)還會(huì)對(duì)所有的導(dǎo)航欄做模糊處理,這樣可以讓iOS 7中導(dǎo)航欄的顏色更加飽和。如下圖,是translucent值為NO和YES的對(duì)比效果: \ 要想禁用translucent屬性,可以在Storyboard中選中導(dǎo)航欄,然后在Attribute Inspectors中,取消translucent的勾選。 在導(dǎo)航欄中使用背景圖片 如果希望在導(dǎo)航欄中使用一個(gè)圖片當(dāng)做背景,那么你需要提供一個(gè)稍微高一點(diǎn)的圖片(這樣可以延伸到導(dǎo)航欄背后)。導(dǎo)航欄的高度從44 points(88 pixels)變?yōu)榱?4 points(128 pixels)。 我們依然可以使用setBackgroundImage:方法為導(dǎo)航欄設(shè)置自定義圖片。如下代碼所示: ? 1 1 ? 1 2 [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg.png"] forBarMetrics:UIBarMetricsDefault]; 示例工程中提供了兩個(gè)背景圖片:nav_bg.png 和 nav_bg_ios7.png。運(yùn)行一下試試看吧,如下效果: \ 定制返回按鈕的顏 在iOS 7中,所有的按鈕都是無(wú)邊框的。其中返回按鈕會(huì)有一個(gè)V型箭頭,以及上一個(gè)屏幕中的標(biāo)題(如果上一屏幕的標(biāo)題是空,那么就顯示”返回”)。要想給返回按鈕著色,可以使用tintColor屬性。如下代碼所示: ? 1 1 ? 1 2 [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; 除了返回按鈕,tintColor屬性會(huì)影響到所有按鈕標(biāo)題和圖片。 \ 如果想要用自己的圖片替換V型,可以設(shè)置圖片的backIndicatorImage和backIndicatorTransitionMaskImage。如下代碼所示: ? 1 2 1 2 ? 1 2 3 [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back_btn.png"]]; [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn.png"]]; 圖片的顏色是由tintColor屬性控制的。 \ 修改導(dǎo)航欄標(biāo)題的字體 跟iOS 6一樣,我們可以使用導(dǎo)航欄的titleTextAttributes屬性來(lái)定制導(dǎo)航欄的文字風(fēng)格。在text attributes字典中使用如下一些key,可以指定字體、文字顏色、文字陰影色以及文字陰影偏移量: UITextAttributeFont – 字體keyUITextAttributeTextColor – 文字顏色keyUITextAttributeTextShadowColor – 文字陰影色keyUITextAttributeTextShadowOffset – 文字陰影偏移量key 如下代碼所示,對(duì)導(dǎo)航欄的標(biāo)題風(fēng)格做了修改: ? 1 2 3 4 5 6 7 1 2 3 4 5 6 7 ? 1 2 3 4 5 6 7 8 NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]; shadow.shadowOffset = CGSizeMake(0, 1); [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, shadow, NSShadowAttributeName, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]]; 運(yùn)行效果如下圖所示: \ 修改導(dǎo)航欄標(biāo)題為圖片 如果要想將導(dǎo)航欄標(biāo)題修改為一個(gè)圖片或者logo,那么只需要使用下面這行代碼即可: ? 1 1 ? 1 2 self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"appcoda-logo.png"]]; 上面的代碼簡(jiǎn)單的修改了titleView屬性,將一個(gè)圖片賦值給它。注意:這不是iOS 7中的新功能,之前的iOS版本就可以已經(jīng)有了。

回答者:henantest2016-04-13 00:00

相關(guān)問(wèn)題

車(chē)友關(guān)注

最新標(biāo)簽

按字母分類(lèi):
ABCDEFGHIJKLMNOPQRSTWXYZ0-9