码迷,mamicode.com
首页 > 移动开发 > 详细

[iOS 前端笔记+小技巧]

时间:2015-04-12 19:07:45      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

 我决定倒着写了。。。

7.给collectioncell加边框 或者给任何view加边框的方法

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 初始化时加载collectionCell.xib文件
        NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"ClassesViewCell" owner:self options:nil];
        // 如果路径不存在,return nil
        if (arrayOfViews.count < 1)
        {
            return nil;
        }
        // 如果xib中view不属于UICollectionViewCell类,return nil
        if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]])
        {
            return nil;
        }
        // 加载nib
        
        self = [arrayOfViews objectAtIndex:0];
        CGFloat borderWidth = 2.0f;
        self.layer.borderWidth=borderWidth;
        self.layer.borderColor=[UIColor colorWithWhite:0.5f alpha:1.0f].CGColor;
    }
    return self;
}

 

这几天做前端得出个经验:

  第一个:Fation的设计实在不好做出来,需要有“机智”的头脑用现有的规则去搭建……比如侧滑这种,苹果没什么框架,开发者硬生生做出了个业界标准来。。。比如tablecell也没有间隔的API,但还是做的出一样的效果。。

  第二个:现在加入了iPhone6和6P之后,整天他妈的要约束来约束去……我要吐了(安卓党肯定表示呵呵)……做iOS前端的工资是不是涨了

 

1.TableViewCell之间有间隔的方法:使用SectionHeader作为间隔,取消SectionHeader在Navbar下的粘滞效果:

自定义SectionHeader

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

{

    UIView *sectionheader=[[UIView alloc]initWithFrame:CGRectMake(0, 0,CGRectGetWidth(self.view.bounds), 20)];

    return sectionheader;
    
}

 

2.TableView隐藏没有数据的CELL,然后加个有线的背景:(不知道有没有更好的方法)

    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

 

3.TableCell在Xib的布局大小会被AutoLayout搞坏。。如图片大小会被Autolayout,想要固定可以使用继承直接写在TableCell.m

(我感觉不大行?)

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.imgview.bounds=CGRectMake(10,10,30,30);
    self.imgview.frame=CGRectMake(10,10,30,30);
    self.imgview.contentMode = UIViewContentModeScaleAspectFill;
}

 

4.快速取得界面宽度

CGRectGetWidth(self.view.bounds)

 5.navigationbar颜色设置:(透明度要不透明才是原色,不然有变,参考http://www.cocoachina.com/industry/20131024/7233.html)

正确的函数是:

    [self.navigationController.navigationBar setBarTintColor:[UIColor brownColor]];

 6.设置tab bar颜色 可以写在appdelegate里(http://www.ui.cn/project.php?id=39325)

    [self.tabBar setTintColor:[UIColor whiteColor]];//设置提示色
    [self.tabBar setBarTintColor:[UIColor brownColor]];//设置背景色 有个bar!

 

[iOS 前端笔记+小技巧]

标签:

原文地址:http://www.cnblogs.com/rayshen/p/4419890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!