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
          主站蜘蛛池模板: 三门峡市| 湛江市| 贺州市| 浮梁县| 开封市| 普兰店市| 迭部县| 黑水县| 兴仁县| 东乡族自治县| 岐山县| 漳浦县| 潢川县| 琼海市| 象州县| 江门市| 惠安县| 永清县| 巴楚县| 聊城市| 资兴市| 德化县| 同仁县| 枣庄市| 汉阴县| 吉安县| 会泽县| 富锦市| 赤水市| 河间市| 富蕴县| 奈曼旗| 交城县| 莲花县| 剑川县| 长武县| 华池县| 峨山| 体育| 杂多县| 麟游县|