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
          主站蜘蛛池模板: 贺州市| 铜陵市| 深泽县| 大悟县| 乌什县| 屏东市| 永春县| 定结县| 包头市| 鄱阳县| 弥勒县| 东乌| 军事| 娄烦县| 肥西县| 青川县| 革吉县| 海南省| 宁南县| 阳朔县| 天峨县| 东辽县| 乌鲁木齐县| 雅江县| 赤水市| 仪征市| 额尔古纳市| 旺苍县| 会泽县| 张家川| 阿合奇县| 晋宁县| 卢龙县| 汝阳县| 望都县| 郑州市| 陕西省| 阿拉尔市| 进贤县| 泸西县| 清镇市|