首页 > 代码库 > 简洁的ios小界面
简洁的ios小界面
下午写写了个小东西小界面
有须要的能够直接拿过来用 ,简洁,挺好看,自我感觉;
写界面事实上就是自上而下的在view加空间,注意一下位置即可了
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { CGRect screenSize = [[UIScreen mainScreen]bounds]; //无货物信息图片 UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 160, 100)]; image.center = CGPointMake(screenSize.size.width/2,screenSize.size.height/2-15-55); image.image = [UIImage imageNamed:@"nocargo.jpg"]; image.backgroundColor = [UIColor orangeColor]; [self addSubview:image]; //你还没有收货地址label UILabel *noLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 160, 30)]; noLabel.center =CGPointMake(screenSize.size.width/2,screenSize.size.height/2 ); noLabel.text = @"您还没有收获地址"; noLabel.textAlignment = NSTextAlignmentCenter; noLabel.font = [UIFont fontWithName:@"Helvetica" size:19]; [self addSubview:noLabel]; //请加入新地址label UILabel *addLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 30)]; addLabel.center =CGPointMake(screenSize.size.width/2,screenSize.size.height/2+30); addLabel.text = @"请加入新地址"; addLabel.textAlignment = NSTextAlignmentCenter; addLabel.font = [UIFont fontWithName:@"Helvetica" size:15]; [self addSubview:addLabel]; //加入新地址button设置 addAddressBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 150, 30)]; addAddressBtn.center = CGPointMake(screenSize.size.width/2,screenSize.size.height-40 ); [addAddressBtn setTitle:@"加入新地址" forState:UIControlStateNormal]; [addAddressBtn addTarget:self action:@selector(addAddressBtnClick) forControlEvents:UIControlEventTouchDown]; addAddressBtn.layer.borderWidth = 1; addAddressBtn.layer.cornerRadius = 5; addAddressBtn.layer.borderColor = [UIColor redColor].CGColor; addAddressBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:18]; addAddressBtn.titleLabel.textColor = [UIColor redColor]; [self addSubview:addAddressBtn]; self.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1]; ; } return self; }
以上就是第一个页面的全部内容;
我们来看一下第二张图吧
xib 中加入控件实现这个效果三个都是label。设置一下字体什么的即可 最后加一个小图片 箭头
注意在地址中我们用到了富文本label 将【默认】设置为红色。看第二幅图。
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)]; attrLabel.attributedText = str;
本段代码来自http://www.cnblogs.com/taintain1984/p/3550525.html;
以下是在设置tablecell的代码。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"cellIdentifier"; NSDictionary *dictionary = [tableArray objectAtIndex:indexPath.row]; TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if(cell==nil) { cell = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:nil options:nil][0]; } cell = [cell setCelldictionary:dictionary]; return cell; }
。
仅仅要加上一句话就够了
self.tableFooterView = [[UIView alloc]init];
self 是tableview。
其它的就没什么了,主要是为了帮忙,写了两个界面。记录一下不熟练的地方。
界面代码下载地址:http://download.csdn.net/detail/u010123208/8013673
简洁的ios小界面
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。