UItabBarとUInavigationBarの内容を設定する方法

2785 ワード

classとstring

[UITabBarButton class] == NSClassFromString(@"UITabBarButton")

[UIButton class] == NSClassFromString(@"UIButton")

@"UITabBarButton" == NSStringFromClass([UITabBarButton class])

UItabBarとUInavigationBarの内容を設定する方法

  • UItabBarの内容
  • UItabBarControllerが管理するサブコントローラのtabBarItem属性決定
  • UInavigationBarの内容
  • UINavigationControllerが管理するサブコントローラのnaivgationItem属性決定

  • ナビゲーションバーのタイトルテキストの設定

  • selfの使用を推奨する.navigationItem.titleはselfに取って代わる.title

  • リッチテキスト

  • コンセプト
  • 属性付きテキスト
  • 組成
  • テキスト(NSString*string)
  • 属性(NSDictionary*attributes)
  • NSAttributedString
  • NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    attrs[NSUnderlineStyleAttributeName] = @(NSUnderlineStyleSingle);
    label.attributedText = [[NSAttributedString alloc] initWithString:@" " attributes:attrs];
  • NSMutableAttributedString
  • NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@" "];
    
    [string addAttributes:@{
                        NSForegroundColorAttributeName : [UIColor blueColor],
                        NSBackgroundColorAttributeName : [UIColor yellowColor]
                        } range:NSMakeRange(1, 2)];
    
    [string addAttribute:NSUnderlineColorAttributeName value:[UIColor grayColor] range:NSMakeRange(0, 6)];
    
    [string setAttributes:@{
                            NSFontAttributeName : [UIFont systemFontOfSize:25]
                            } range:NSMakeRange(1, 2)];
    
    // addXXX :  
    // setXXX :  ,