IOS设置View的背景图片
2016-06-02 08:43
666 查看
1.设置一般View的背景
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imgName.png"]];
imgView.frame = self.view.bounds;
imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view insertSubview:imgView atIndex:0];
2.设置View的背景颜色,使用图片,效果和设置背景图片比较类似
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"imgName.png"]]];
3.设置UITableView的背景
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imgName.png"]];
imgView.frame = self.view.bounds;
imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.tableView setBackgroundView:imgView];
4.设置UITableView的cell颜色
//方法一:
cell.contentView.backgroundColor = [UIColor redColor];
//方法二:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView* bgview = [[UIView alloc]initWithFrame:CGRectMake(0,0,1,1)];
bgview.opaque = YES;
bgview.backgroundColor = [UIColor orangeColor];
[cell setBackgroundView:bgview];
//方法三:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
{
cell.backgroundColor = [UIColor redColor];
}
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imgName.png"]];
imgView.frame = self.view.bounds;
imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view insertSubview:imgView atIndex:0];
2.设置View的背景颜色,使用图片,效果和设置背景图片比较类似
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"imgName.png"]]];
3.设置UITableView的背景
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imgName.png"]];
imgView.frame = self.view.bounds;
imgView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.tableView setBackgroundView:imgView];
4.设置UITableView的cell颜色
//方法一:
cell.contentView.backgroundColor = [UIColor redColor];
//方法二:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView* bgview = [[UIView alloc]initWithFrame:CGRectMake(0,0,1,1)];
bgview.opaque = YES;
bgview.backgroundColor = [UIColor orangeColor];
[cell setBackgroundView:bgview];
//方法三:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
{
cell.backgroundColor = [UIColor redColor];
}
相关文章推荐
- ps字体与ios字体转换
- iOS页面传值-wang
- ios常见的页面传值方式
- iOS内存分配大小
- Xcode Unknown type name 'NSString'
- ios获取设备唯一标识
- ios图文混排
- iOS毛玻璃效果
- ios aes 加密 与 nodejs aes 不一样 解决方法
- IOS博客项目搭建-19-项目重构-封装业务工具类
- iOS沙盒机制
- ios runtime基础知识
- iOS监听系统键盘的弹起和回收
- 【转】【iOS】导航栏那些事儿
- 【转】iOS中设置导航栏标题的字体颜色和大小
- iOS中关于atomic和nonatomic,assign、weak、strong、retain的使用、区别
- iOS 判断字符是全角还是半角
- 根据Facebook内存的管理使用,浅谈在iOS上自动检测内存泄漏问题
- 根据Facebook内存的管理使用,浅谈在iOS上自动检测内存泄漏问题
- iOS监听横竖屛通知