日常杂记--2

1、view页面翻转

    UIViewAnimationOptions option = _isLeft?UIViewAnimationOptionTransitionFlipFromLeft:UIViewAnimationOptionTransitionFlipFromRight;

  // 法一

    [UIView transitionFromView:_view1 toView:_view2 duration:.35 options:option completion:nil];

   //法二

    [UIViewtransitionWithView:self.contentViewduration:.35options:option animations:^{

        [self.contentViewexchangeSubviewAtIndex:0withSubviewAtIndex:1];

    } completion:^(BOOL finished) {

    }];

    //法三

    [UIViewanimateWithDuration:.55animations:^{

        [UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromLeftforView:self.viewcache:YES];

    }];

2、添加下划线或者某段标红

    NSString *string = @"注册即表示同意《用户协议》";

    NSMutableAttributedString *eulaTitle = [[NSMutableAttributedStringalloc] initWithString:string];

    [eulaTitle addAttributes:@{NSUnderlineStyleAttributeName:@NO,

                               NSForegroundColorAttributeName:[UIColormainThemeColor]}

                       range:[string rangeOfString:@"《用户协议》"]];

    [eulaTitle addAttribute:NSForegroundColorAttributeNamevalue:[UIColorminorTextColor] range:[string rangeOfString:@"注册即表示同意"]];

3、过滤空格

  去除左右两段空格

  [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

  去除所有空格

  [string stringByReplacingOccurrencesOfString:@" " withString:@""]

4、系统View自动比例适配(没啥蛋用)

  UIView 中autoresizingMask的属性

  UIViewAutoresizingNone就是不自动调整。
  UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变。
  UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与superView左边的距离不变。
  UIViewAutoresizingFlexibleTopMargin 自动调整与superView顶部的距离,保证与superView底部的距离不变。
  UIViewAutoresizingFlexibleBottomMargin 自动调整与superView底部的距离,也就是说,与superView顶部的距离不变。
  UIViewAutoresizingFlexibleWidth 自动调整自己的宽度,保证与superView左边和右边的距离不变。
  UIViewAutoresizingFlexibleHeight 自动调整自己的高度,保证与superView顶部和底部的距离不变。
  UIViewAutoresizingFlexibleLeftMargin  |UIViewAutoresizingFlexibleRightMargin 自动调整与superView左边的距离,保证与左边的距离和右边的距离和原来距左边和右边的距离的比例不变。比如原来距离为20,30,调整后的距离应为68,102,即68/20=102/30。

5、block是以对象形式在程序中运行的,会大大导致程序变大,尽量不要使用mansory来进行界面布局,因为他采用的全是block

    宏定义虽然定义一次,在程序编译的时候会一直存在,增加编译速度,但是他会存在占内存中,拖累程序运行速度,最好的大规模的宏可以以文件方式来存储。

 6、UILabel自动换行

    testLabl.numberOfLines = 0;

    testLabl.lineBreakMode = NSLineBreakByWordWrapping;

7、设置图片

  使用ImageName 可以获得到所有路径的图片,包括文件内和assets中的图片,适合加载多次使用的icon

  缺点:会把图片加载到缓存中

  imageContentFile 可以加载文件夹内的图片,获取不到assets中的图片,不会缓存图片,适合加载大图和只使用一次的icon

  缺点:获取不到assets中的图片。

 

  assets:会自动根据图片生成一倍图、二倍图、三倍图

  文件内:不能自动生成二倍图,三倍图,会存在拉伸图片

8、UINavgationController的返回按钮可根据ViewControllers的个数来判断是否需要隐藏,大于1显示,小于或等于1隐藏,不用每次都穿是否隐藏的状态。 

posted @ 2018-01-10 09:18  菜鸟好笨笨!  阅读(130)  评论(0编辑  收藏  举报