ios 技巧2- 读书笔记

来源:互联网 发布:启用视频网络 编辑:程序博客网 时间:2024/06/05 03:48

 修改segment中字体的大小和颜色 

NSDictionary *textDic = [NSDictionary dictionaryWithObjectsAndKeys:

                             [[UIColor blackColor]       colorWithAlphaComponent:0.6f],UITextAttributeTextColor,
                             [UIColor blackColor],UITextAttributeTextShadowColor,
                             [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],UITextAttributeTextShadowOffset,
                             [UIFont systemFontOfSize:13],UITextAttributeFont,nil];
    NSDictionary *highTextDic = [NSDictionary dictionaryWithObjectsAndKeys:
                             [[UIColor whiteColor]       colorWithAlphaComponent:1.0f],UITextAttributeTextColor,
                             [UIColor whiteColor],UITextAttributeTextShadowColor,
                             [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],UITextAttributeTextShadowOffset,
                             [UIFont systemFontOfSize:13],UITextAttributeFont,nil];


 重写navigation的属性 

    [self.Navbtnitem_segment setTitleTextAttributes:textDic forState:UIControlStateNormal];

    [self.Navbtnitem_segment setTitleTextAttributes:highTextDic forState:UIControlStateSelected];

self.navigationController.view.backgroundColor = [UIColor clearColor];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >=7.0) {
        self.navigationController.navigationBar.translucent = YES; //禁止半透明毛玻璃效果
        self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; //返回按钮颜色
        self.navigationController.navigationBar.barTintColor = [UIColor clearColor]; //bar背景颜色
        [self.navigationController.navigationBar setBackgroundColor:[UIColor clearColor]];
        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}; //标题颜色
        self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    }else{
        [self.navigationController.navigationBar setTintColor:[UIColor clearColor]]; //bar背景颜色
        self.navigationController.navigationBar.translucent = NO;
        self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:18]};
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }


给label添加分割线

 NSString *oldPrice = [NSString stringWithFormat:@"%@",obj];
            NSUInteger length = [oldPrice length];

            NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];
            [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
            [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, length)];
            [labelAnswer setAttributedText:attri]; 



0 0
原创粉丝点击