设置view背景颜色方法

1.调用- (void)drawRect:(CGRect)rect方法

- (void)drawRect:(CGRect)rect

{

    [[UIImage resizedImage:@"bg_buyBtn.png"] drawInRect:rect];

 

}

 

2.第二种方法

#pragma mark 添加一个全屏的背景

- (void)setupBg

{

    UIImageView *bg = [[UIImageView alloc] initWithFrame:self.view.bounds];

    bg.image = [UIImage imageNamed:is4inch?@"LuckyBackground-568h@2x.jpg":@"LuckyBackground@2x.jpg"];

    bg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    [self.view addSubview:bg];

 

}

3:第三种方法

// 2.设置背景

 

        self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_tabbar.png"]];

 

4:tableView设置背景颜色

// 设置背景

tableView.backgroundView = nil;

 

tableView.backgroundColor = ILGlobalBg;

 

5:UITableViewCell

#pragma mark 设置背景

- (void)setupBg

{

    // 1.默认

    UIView *bg = [[UIView alloc] init];

    bg.backgroundColor = [UIColor whiteColor];

    self.backgroundView = bg;

 

    // 2.选中

    UIView *selectedBg = [[UIView alloc] init];

    selectedBg.backgroundColor = ILColor(237, 233, 218);

    self.selectedBackgroundView = selectedBg;

 

}

posted on 2015-07-17 16:31  pTrack  阅读(1932)  评论(0)    收藏  举报