设置Table Cell的背景图的公用类
来源:互联网 发布:在淘宝开网店赚钱吗 编辑:程序博客网 时间:2024/05/17 02:15
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UITableViewCell (UITableViewCellExt)
- (void)setBackgroundImage:(UIImage*)image;
- (void)setBackgroundImageByName:(NSString*)imageName;
@end
#import "UITableViewCellExt.h"
@implementation UITableViewCell (UITableViewCellExt)
- (void)setBackgroundImage:(UIImage*)image
{
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.contentMode = UIViewContentModeCenter;
self.backgroundView = imageView;
[imageView release];
}
- (void)setBackgroundImageByName:(NSString*)imageName
{
[self setBackgroundImage:[UIImage imageNamed:imageName]];
}
@end
调用示例:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell setBackgroundImageByName:@"text-background.png"];
}
return cell;
}
- 设置Table Cell的背景图的公用类
- 设置Table Cell的背景图的公用类
- 设置Table Cell的背景图的类
- 设置 cell 的背景色,背景图 ,选中效果
- 设置UIToolbar的背景图
- 设置背景图的自适应
- 背景图的设置
- 神奇的table-cell
- Android设置窗口的背景图
- Android设置窗口的背景图
- java设置jPanel的背景图
- 设置磨砂效果的背景图
- Table---自定义cell的背景
- display:table-cell的妙用
- display:table-cell的应用
- display:table-cell的 应用
- display:table-cell的用法
- display:table-cell的应用
- VS2010报错:“无法嵌入互操作类型”解决方法
- xcode4.2/xcode4.3 ios开发_离线阅读iPhone SDK文档
- ubuntu设置固定IP
- Problem 58 怎样判断当前程序链接的是多线程版的Glibc还是单线程版的Glibc?
- Android之TextView实现文字过长时省略部分或者滚动显示
- 设置Table Cell的背景图的公用类
- 【JAVA】Class.forName( )你搞懂了吗
- 小波包分解
- Problem 59 GCC密切相关的一些环境变量?
- C# 线程间操作无效: 从不是创建控件...的解决办法
- 浅谈Overload和Override的区别
- Android4: 动态切换界面风格
- /*题目:猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个
- hibernate的级联、延迟加载、inverse属性