2011年12月1日 星期四

Lala's Program Note 實作記錄: 33. 幫 NoteBook 的 TableView 設定背景圖片


since: 2011/12/01
update: 2011/12/02

A. 修改 NoteBookViewController.h 如下:

//@add
- (void)setBackgroundImage:(UIImage *)image;

---------------------------------------------------------------------------------------------

B. 修改 NoteBookViewController.m 如下:


//@add
- (void)setBackgroundImage:(UIImage *)image {
    //UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   
    imageView.backgroundColor = [UIColor colorWithPatternImage:image]; 
   
    //設定圖片的透明度 值為 0.0 ~ 1.0(圖片隱藏~完全不隱藏)
    [imageView setAlpha:0.32];
   
    [self.view addSubview:imageView];
    [self.view sendSubviewToBack:imageView];
    //[self.view insertSubview:imageView atIndex:0];
   
    [self.view setOpaque:NO];
    [self.view setBackgroundColor:[UIColor clearColor]];
    //set contentMode to scale aspect to fit
    imageView.contentMode = UIViewContentModeScaleAspectFit;

    [imageView release];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
   
    //@add
    SEL segmentAction = @selector(segmentAction:);
   
    self.navigationItem.rightBarButtonItem = [self segmentBarItemMakeWithSelector:segmentAction btn1Name:@"Trash" btn2Name:@"Add"];

    //@add setBackgroundImage
    [self setBackgroundImage:[UIImage imageNamed:@"pipi_NoteBook.png"]];
    [self.view setNeedsDisplay];
}

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。