美文网首页
IOS开发笔记

IOS开发笔记

作者: 醉影 | 来源:发表于2017-07-14 14:37 被阅读4次

    1.使用定时器时,避免移动界面时,导致定时器暂停:

    [[NSRunLoop currentRunLoop] addTimer: self.timer forMode:NSRunLoopCommonModes];

    2.屏幕旋转

     2.1阻止点击要旋转的视图

    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController*)viewController


    2.1.在AppDelegate 中添加

    - (UIInterfaceOrientationMask) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    if ([self.window.rootViewController isEqual: self.testVC]) { //要旋转的跟控制器

    return UIInterfaceOrientationMaskLandscapeLeft;

    }

    return UIInterfaceOrientationMaskPortrait;

    }



    3.关于Label删除线问题

    在iOS 10.3 以后系统的删除线功能不能实现

    if ([UIDevice currentDevice].systemVersion.floatValue >= 10.3f) {

    UILabel * dLabel = [[UILabel alloc] init];

    CGFloat width1=[(NSString *) label2.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(label2.width,100)].width-8;

    dLabel.center = CGPointMake(label2.width/2, label2.height/2);

    dLabel.bounds = CGRectMake(0, 0, width1, 1);

    dLabel.backgroundColor = [UIColor grayColor];

    [label2 addSubview: dLabel];

    } else {

    NSAttributedString *attrStr = [[NSAttributedString alloc]initWithString: label2.text  attributes: @{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid)}];

    label2.attributedText = attrStr;

    }


    相关文章

      网友评论

          本文标题:IOS开发笔记

          本文链接:https://www.haomeiwen.com/subject/ndanhxtx.html