字体,不同颜色混排

    

    NSArray *familyNames = [[NSArrayalloc]initWithArray:[UIFontfamilyNames]];

    

    NSArray *fontNames;

    

    NSInteger indFamily, indFont;

    

    for (indFamily=0; indFamily<[familyNamescount]; ++indFamily)

        

    {

        

        NSLog(@"Family name: %@", [familyNamesobjectAtIndex:indFamily]);

        

        fontNames = [[NSArray alloc] initWithArray:

                     

                     [UIFont fontNamesForFamilyName:

                      

                      [familyNames objectAtIndex:indFamily]]];

        

        for (indFont=0; indFont<[fontNamescount]; ++indFont)

            

        {

            

            NSLog(@"    Font name: %@", [fontNamesobjectAtIndex:indFont]);

            

        }

        

    }




 NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:@"52元起,走遍全球都不怕!\n全球旅游险为您提供医疗费用补偿、 航班延误、托运行李丢失等13项保障,更享24小时紧急支援服务,保额高达270万元。"];
        
        [attriString addAttribute:NSFontAttributeName
                            value:[UIFont systemFontOfSize:15]
                            range:NSMakeRange(0, attriString.length)];
        [attriString addAttribute:NSForegroundColorAttributeName
                            value:[UIColor redColor]
                            range:NSMakeRange(0, 4)];
        [attriString addAttribute:NSForegroundColorAttributeName
                            value:[UIColor redColor]
                            range:NSMakeRange(43, 5)];
        [attriString addAttribute:NSForegroundColorAttributeName
                            value:[UIColor redColor]
                            range:NSMakeRange(66, 5)];










- (void)colorChange:(UIColor *)color{
    
    const CGFloat *nowColor = CGColorGetComponents(color.CGColor);
    NSString *str = [NSString stringWithFormat:@"#%.2x%.2x%.2x",(NSInteger)(nowColor[0]*255),(NSInteger)(nowColor[1]*255),(NSInteger)(nowColor[2]*255)];
    
    NSLog(@"str = %@",str);
    _bcolorStr = str;
    
    [head changeTheBColor:color];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值