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 閱讀(1121) 評論(0)  編輯  收藏 所屬分類: iPhone
          主站蜘蛛池模板: 甘德县| 贞丰县| 梓潼县| 太和县| 汪清县| 都兰县| 呼伦贝尔市| 图们市| 平泉县| 安吉县| 高淳县| 翁源县| 紫金县| 万州区| 银川市| 台山市| 罗山县| 禄丰县| 贵港市| 泰州市| 子洲县| 博白县| 克什克腾旗| 夏河县| 江达县| 潜江市| 额济纳旗| 敦煌市| 阿尔山市| 临桂县| 麦盖提县| 汝阳县| 玉田县| 安远县| 高州市| 乐至县| 育儿| 如皋市| 江山市| 磐安县| 方山县|