论坛首页 移动开发技术论坛

iPhone设置视图背景图片的方法

浏览 9844 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-03-02   最后修改:2009-03-02
iOS
方法一,使用一个UIImageView实例做子视图,并且放最后面

- (void)setBackgroundImage {
    NSLog(@"setting bg image");
    UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];
    self.background = customBackground;
    [customBackground release];
    
    [self addSubview:background];
    NSLog(@"Added background subview %@", background);
    [self sendSubviewToBack:background];
}


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

- (void)loadView {
    
    UIImageView *contentView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [contentView setImage:[UIImage imageNamed:@"Default.png"]];
    [contentView setUserInteractionEnabled:YES];
    self.view = contentView;
    [contentView release];
}


方法三,lvyile网友用的一个小技巧,uiView是UIView的实例,而不是UIImageView

uiView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]];
   发表时间:2009-03-03  
不错, 对Apple SDK的不熟悉... 真苦恼... 新手的困惑~~~
往往一个东西要找几个小时...
0 请登录后投票
   发表时间:2009-03-05  
很好,这些东西是做Iphone开发的基础
0 请登录后投票
   发表时间:2009-03-14  
这篇文字是想要讲什么呢?我看见过如何设置 iphone的录像了,直接操作的,给你们一个链接去下载看看,我不知道是不是真的你们需要的,虽然比较笨蛋了我。
http://www.verycd.com/topics/172567/
《Iphone高清演示视频及操作手册》[PDF&MP4]
0 请登录后投票
   发表时间:2009-03-14  
lordhong 写道
不错, 对Apple SDK的不熟悉... 真苦恼... 新手的困惑~~~
往往一个东西要找几个小时...


大哥,你好,只是想学习学习,好奇问你,是讲谁呢?谁是新手,那位楼主是吗,希望能回答。谢谢。
干嘛要这么弄呢。这个楼主设置视图背景图片的方法,是在解析iphone的程序执行过程是如何是吗?不明白,希望多多说说。
0 请登录后投票
   发表时间:2009-03-14  
richardlovejob 写道
lordhong 写道
不错, 对Apple SDK的不熟悉... 真苦恼... 新手的困惑~~~
往往一个东西要找几个小时...


大哥,你好,只是想学习学习,好奇问你,是讲谁呢?谁是新手,那位楼主是吗,希望能回答。谢谢。
干嘛要这么弄呢。这个楼主设置视图背景图片的方法,是在解析iphone的程序执行过程是如何是吗?不明白,希望多多说说。


我是在讲我自己啊... -__-#

这3个方法是iPhone设置视图背景图片3种不同方法, 各有各的适用场合.
0 请登录后投票
论坛首页 移动开发技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics