• [iOS UI设计笔记整理汇总]


    8.UIsearchbar放到Navigationbar 上(意思是建个View作为titleview)

        //此处调用的是第三方封装的SearchBar,也可以自定义。
    self.searchBarWithDelegate = [[INSSearchBar alloc] initWithFrame:CGRectMake(0, 5, 44.0, 44.0)]; self.searchBarWithDelegate.delegate = self; UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 768, 44)]; searchView.backgroundColor = [UIColor clearColor]; [searchView addSubview:self.searchBarWithDelegate]; UILabel *descriptionLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(45.0, 0, 80, 44)]; descriptionLabel2.textColor = [UIColor whiteColor]; descriptionLabel2.font = [UIFont fontWithName:@"AvenirNext-Regular" size:18.0]; descriptionLabel2.text = @"找点东西"; [searchView addSubview:descriptionLabel2]; self.navigationItem.titleView = searchView;

    我决定倒着写了。。。

    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;
    //另外修改样式tableview样式为grouped

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

    (感觉直接XIB里加约束比较靠谱)

    -(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!
  • 相关阅读:
    springboot学习入门简易版二---springboot2.0项目创建
    springboot学习入门简易版一---springboot2.0介绍
    mybatis学习系列一(mybatis简介/使用)
    mybatis学习系列--逆向工程简单使用及mybatis原理
    mybatis学习系列五--插件及类型处理器
    enum类使用
    mybatis学习系列四--mybatis generator逆向工程
    mybatis学习系列三(部分)
    常见开源协议及含义
    【maven】常见插件
  • 原文地址:https://www.cnblogs.com/rayshen/p/4419890.html
Copyright © 2020-2023  润新知