Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks
          方法一,使用一個UIImageView實例做子視圖,并且放最后面

          Objective-c代碼
          1. - (void)setBackgroundImage {  
          2.     NSLog(@"setting bg image");  
          3.     UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];  
          4.     self.background = customBackground;  
          5.     [customBackground release];  
          6.       
          7.     [self addSubview:background];  
          8.     NSLog(@"Added background subview %@", background);  
          9.     [self sendSubviewToBack:background];  
          10. }  


          方法二,Cook Book中提到的方法

          Objective-c代碼
          1. - (void)loadView {  
          2.       
          3.     UIImageView *contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];  
          4.     [contentView setImage:[UIImage imageNamed:@"Default.png"]];  
          5.     [contentView setUserInteractionEnabled:YES];  
          6.     self.view = contentView;  
          7.     [contentView release];  
          8. }  


          方法三,lvyile網友用的一個小技巧,uiView是UIView的實例,而不是UIImageView

          Objective-c代碼
          1. uiView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]]; 
          posted on 2010-10-08 16:04 seal 閱讀(1129) 評論(0)  編輯  收藏 所屬分類: iPhone
          主站蜘蛛池模板: 集贤县| 岑巩县| 广宁县| 县级市| 弥勒县| 临沧市| 康保县| 大足县| 城市| 威远县| 资中县| 历史| 历史| 昔阳县| 锡林浩特市| 中宁县| 奉化市| 全南县| 沭阳县| 依兰县| 新建县| 饶河县| 报价| 柞水县| 天全县| 闽侯县| 卢龙县| 黔西县| 隆回县| 正定县| 商南县| 安义县| 建水县| 松原市| 肇庆市| 新龙县| 张家口市| 嫩江县| 沁阳市| 柳江县| 岳阳市|