一些常用合集

** 好记性不如烂笔头 记录一些自己在开发中经常用到的一些琐碎代码片段 会经常更新 .. **


1、目前iOS项目中要求导航栏的返回按钮只保留那个箭头,去掉后边的文字,在网上查了一些资料,最简单且没有副作用的方法就是

[UIBarButtonItem appearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0,-60)] for BarMetrics:UIBarMetricsDefault];


2、简单实现一个导航栏的下的提示视图 效果如下

未命名.gif
- (void)showNewStatusesCount:(NSInteger)nums{

    UILabel *label = [[UILabel alloc] init];
    label.font = [UIFont systemFontOfSize:12];
    
    if (nums) {
        label.text = [NSString stringWithFormat:@"新%ld条数据", count];
    } else {
        label.text = @"暂无新数据";
    }
    
    label.backgroundColor = [UIColor colorWithRed:0/255.0  green:174/255.0 blue:22/255.0 alpha:1.0];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    
    label.width = self.view.frame.size.width;
    label.height = 35;
    label.x = 0;
    label.y = CGRectGetMaxY([self.navigationController navigationBar].frame) - label.frame.size.height;
    
    [self.navigationController.view insertSubview:label belowSubview:self.navigationController.navigationBar];

    [UIView animateWithDuration:.8f; animations:^{

        label.transform = CGAffineTransformMakeTranslation(0, label.frame.size.height);

    } completion:^(BOOL finished) { /
       
        [UIView animateWithDuration:duration delay:.8f options:UIViewAnimationOptionCurveEaseInOut animations:^{
            
            label.transform = CGAffineTransformIdentity;
            
        } completion:^(BOOL finished) {
           
            [label removeFromSuperview];
        }];
    }];
}

3、平时有用到更改label的行间距 使其排版看起来更美观


屏幕快照 2017-01-17 下午2.25.27.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,609评论 25 709
  • 内容抽屉菜单ListViewWebViewSwitchButton按钮点赞按钮进度条TabLayout图标下拉刷新...
    皇小弟阅读 47,000评论 22 665
  • 是谁的歌声悠扬, 是谁的舞姿惊艳全场? 是绵绵细雨停了, 是柔柔的阳光照进我的窗。 风吹雨成花, 窗棂声声响。 滴...
    王新屏阅读 1,001评论 0 0
  • 你在别人的生活中 如沐春风 在我的世界里 踽踽独行 你存在在我存在的时空 像个黑洞 收藏了所有的秘密 吞噬了一个又...
    铁瓮城主阅读 1,287评论 0 0
  • 深夜,听到心跳声 看见一个忙碌的自己 台灯的光线下 影子怪诞的长 仿佛一个陌生的人在遐想 听一曲名叫Bella的口...
    凯歌儿阅读 2,649评论 0 3