自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone開(kāi)發(fā)中為UINavigationBar設(shè)置背景圖片方法

移動(dòng)開(kāi)發(fā) iOS
iPhone開(kāi)發(fā)中為UINavigationBar設(shè)置背景圖片方法是本文要介紹的內(nèi)容,在iPhone開(kāi)發(fā)中, 有時(shí)候我們想給導(dǎo)航條添加背景圖片, 實(shí)現(xiàn)多樣化的導(dǎo)航條效果,具體內(nèi)容來(lái)看本文。

iPhone開(kāi)發(fā)中為UINavigationBar設(shè)置背景圖片方法是本文要介紹的內(nèi)容,在iPhone開(kāi)發(fā)中, 有時(shí)候我們想給導(dǎo)航條添加背景圖片, 實(shí)現(xiàn)多樣化的導(dǎo)航條效果, 用其他方法往往無(wú)法達(dá)到理想的效果, 經(jīng)過(guò)網(wǎng)上搜索及多次實(shí)驗(yàn), 確定如下最佳實(shí)現(xiàn)方案。

為UINavigatonBar增加如下Category:

  1. @implementation UINavigationBar (CustomImage)     
  2. - (void)drawRect:(CGRect)rect {     
  3.     UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];     
  4.     [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];     
  5. }     
  6. @end    

例如, 在我的項(xiàng)目中, 添加如下代碼:

  1. /* input: The image and a tag to later identify the view */     
  2. @implementation UINavigationBar (CustomImage)     
  3. - (void)drawRect:(CGRect)rect {     
  4.     UIImage *image = [UIImage imageNamed: @"title_bg.png"];     
  5.     [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];     
  6. }     
  7. @end     
  8.  
  9. @implementation FriendsPageViewController     
  10. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.     
  11. - (void)viewDidLoad {        
  12.     self.navigationBar.tintColor = [UIColor purpleColor];     
  13.          
  14.     [self initWithRootViewController:[[RegPageViewController alloc] init]];     
  15.     [super viewDidLoad];     
  16. }    

實(shí)現(xiàn)的效果如下圖:

iPhone開(kāi)發(fā)中為UINavigationBar設(shè)置背景圖片方法

小結(jié):iPhone開(kāi)發(fā)中為UINavigationBar設(shè)置背景圖片方法的內(nèi)容介紹完了,希望通過(guò)本文的學(xué)習(xí)能對(duì)你有所幫助!

責(zé)任編輯:zhaolei 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-08-18 13:27:15

CSS兼容IE6

2010-09-09 14:38:05

CSS背景圖片

2010-08-26 10:26:44

CSS

2011-09-01 15:16:00

Ubuntu

2009-03-19 08:54:15

Windows 7定制登陸界面

2010-10-13 08:57:06

Visual Stud

2010-04-27 11:35:05

Oracle Java

2011-06-03 14:04:11

Android

2020-12-16 07:29:23

Windows10操作系統(tǒng)動(dòng)態(tài)鎖屏

2011-08-08 15:48:13

iPhone TableView 背景

2010-09-07 08:54:18

CSSbackground-

2010-11-23 10:51:45

UI交互設(shè)計(jì)產(chǎn)品管理

2009-11-09 19:59:47

2011-09-07 16:24:10

Qt Widget

2011-03-16 11:22:16

iconDefaultiPhone

2011-08-29 17:58:19

Ubuntu

2011-08-08 14:07:49

iPhone開(kāi)發(fā) 字體

2011-08-15 09:58:25

iPhoneXib文件UITableView

2011-08-16 18:56:11

iPhone開(kāi)發(fā)Three20

2019-03-14 08:47:49

Visual Stud數(shù)據(jù)開(kāi)發(fā)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)