ios 写枚举
来源:互联网 发布:四月份非农数据 编辑:程序博客网 时间:2024/06/07 01:09
.h文件中。。。
typedef NS_OPTIONS(NSUInteger, LoginOrReg_phone) { //NSUInteger枚举类型,LoginOrReg_phone枚举名称
loginPhoneType = 0, // 登录的状态
regPhoneType = 1 // 注册的状态
};
申明一个属性
@property LoginOrReg_phone loginOrReg_phone;
.m文件中。。。用switch 进行分类switch (_loginOrReg_phone) {
caseloginPhoneType:
{
UILabel *asd = [[UILabelalloc]initWithFrame:CGRectMake(14.0f,registered.bottom+25.0f/2,SCREEN_WIDTH-28,25)];
[asd setBackgroundColor:[UIColorredColor]];
[self.viewaddSubview:asd];
}
break;
caseregPhoneType:
{
RTLabel *state = [[RTLabelalloc] //RTLabel的使用
initWithFrame:CGRectMake(10.0f,registered.bottom+20.0f/2 , SCREEN_WIDTH-2, 30)];
[self.viewaddSubview:state];
NSString *text =@"<font color='#999999'>点击上面的 “注册”按钮,即表示你同意“聚汇”的<font color='#0D6396'><a href='http://www.baidu.com'>服务条款</a></font>和<font color='#0D6396'><a href='http://www.sina.com'>隐私政策</a></font></font>";
state.delegate = self;
[state setText:text];
}
break;
default:
break;
}
#pragma mark RTLabel点击链接地址
-(void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSString *)url
{
}
在同一个tableView中使用两种风格的cell
cell.h 文件中。。。。
typedef enum {
CellTypeGroup, //好友分组
CellTypeFriend, //好友
}CellType;
//-------------------------分组-----------------------
@property (strong,nonatomic)UILabel *groupName; //分组名称
@property (strong,nonatomic)UILabel *groupDesc; //分组描述
//-------------------------好友-----------------------
@property (strong,nonatomic)SelectButton *selectButton;
@property (strong,nonatomic)UILabel *friendName; //好友名称
@property (strong,nonatomic)UIImageView *stateImage; //状态
//初始化方法
-(id)initWithCellType:(CellType)type reuseIdentifier:(NSString *)reuseIdentifier;
.m文件中。————————
-(id)initWithCellType:(CellType)type reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [superinitWithStyle:UITableViewCellStyleDefaultreuseIdentifier:reuseIdentifier]) {
int cell_width = 300;
if (IOS_DEVICE >=7) {
cell_width = 320;
}
//------好友分组单元格------
if (type == CellTypeGroup)
{
//分组名称
self.groupName = [[UILabelalloc]initWithFrame:CGRectMake(LEFTMARGIN,10, 0 , 0)];
self.groupName.backgroundColor = [UIColorclearColor];
self.groupName.font = [UIFontsystemFontOfSize:FONT_SIZE_FTN]; //字体大小
[self.contentViewaddSubview:self.groupName];
//分组描述
self.groupDesc = [[UILabelalloc]initWithFrame:CGRectMake(LEFTMARGIN,35, 200 , 25)];
self.groupDesc.backgroundColor = [UIColorclearColor];
self.groupDesc.textColor = [UIColorgrayColor]; //字体颜色
self.groupDesc.font = [UIFontsystemFontOfSize:FONT_SIZE_TWE]; //字体大小
[self.contentViewaddSubview:self.groupDesc];
}
//---------好友单元格---------
else if (type ==CellTypeFriend)
{
//创建选择按钮
self.selectButton = [[SelectButtonalloc]initWithFrame:CGRectMake(260,15, 30, 30)];
self.selectButton.tag =1;
self.selectButton.hidden =YES;
[self.contentViewaddSubview:self.selectButton];
//好友状态
self.stateImage = [[UIImageViewalloc]initWithFrame:CGRectMake(self.headImage.frame.size.width-20,0, 20, 20)];
[self.headImageaddSubview:self.stateImage];
//好友名称
self.friendName = [[UILabelalloc]initWithFrame:CGRectMake(LEFTMARGIN,10, 0 , 0)];
self.friendName.backgroundColor = [UIColorclearColor];
self.friendName.font = [UIFontsystemFontOfSize:FONT_SIZE_FTN]; //字体大小
[self.contentViewaddSubview:self.friendName];
}
self.type = type;
}
return self;
}
在Controller.m中使用
#pragma mark-定制cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//设置cell类型
CellType type;
static NSString *cellIndef;
if (indexPath.section ==0) {
type = CellTypeGroup;
cellIndef = @"1";
}
if (groupArr.count ==0) {
type = CellTypeFriend;
cellIndef = @"3";
}
//创建自定义cell
FriendCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndef];
if (!cell) {
cell = [[FriendCell alloc]initWithCellType:type reuseIdentifier:cellIndef];
cell.delegate = self;
}
//新的朋友and未分组好友
if (indexPath.section ==0 && type == CellTypeGroup) {
cell.groupName.text =name[indexPath.row]; //获取分组名称
[cell.groupName sizeToFit]; //分组名Label自适应大小
cell.groupDesc.text =desc[indexPath.row]; //获取分组描述
}
//好友-第二分组
if (type == CellTypeFriend) {
NSString *key = keyArr[indexPath.section];
NSArray *persons = [PersonDictobjectForKey:key];
[cell writePersonModel:person];
}
return cell;
}
- ios 写枚举
- iOS 枚举
- ios枚举
- iOS枚举
- iOS 枚举
- ios 枚举
- iOS-枚举
- iOS枚举(位移枚举)
- iOS中枚举用法
- ios--枚举学习
- ios的枚举ENUM
- ios 枚举 位移操作
- ios枚举的写法
- iOS 枚举使用
- iOS 枚举类型使用
- iOS 定义枚举
- ios之快速枚举
- IOS枚举学习
- jQuery按段分页
- JasperReport报表设计总结(三)(已完毕)
- 返回顶部 and 导航置顶
- HTML网站服务器,一个常看到的知识
- HTML中输入域(INPUT)变灰
- ios 写枚举
- 关于Java奇数最后一个字符输出乱码问题
- centos 6.4 安装lspci
- redis安装 phpredis扩展
- 仿Iphone样式的时间、日期选择器
- 2014-项目一--体验常成员函数
- [java]下拉框显示图文详情
- 壹縷快樂只有妳
- Xcode Cannot Run on the Selected Destination