簡潔的ios小介面

來源:互聯網
上載者:User

簡潔的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];                //添加新地址按鈕設定        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;}

 

 

 

最後有一個地方就是我們寫完tableview的時候是第三幅圖的樣子,後面沒有內容了但是還是有表格線,那我們怎麼辦呢。。

只要加上一句話就夠了

 

 

self.tableFooterView = [[UIView alloc]init];
 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.