[objective-c]storyboardを入れ替える

storyboardを入れ替える

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Setting" bundle:nil];
UIViewController * vc = [storyboard instantiateInitialViewController];
[UIApplication sharedApplication].keyWindow.rootViewController=vc;

[objective-c]UINavigationControllerをaddChild

UINavigationControllerをaddChildしたりremoveFromParentViewControllerしたり

UIViewController*cv=[[UIViewController alloc]init];
UINavigationController*nc=[[UINavigationController alloc]initWithRootViewController:cv];
[self addChildViewController:nc];
[containerView addSubview:nc.view];//containerViewはUIView
currentCV=cv;

[currentCV.navigationController removeFromParentViewController];
[currentCV removeFromParentViewController];
[currentCV.view removeFromSuperview];
currentCV=nil;

[objective-c]UILabelの文字間を設定

UILabelの文字間を設定

-(void)setLetterSpacing:(UILabel*)label letterSpacing:(float)letterSpacing{
    NSMutableAttributedString* attributedText= [[NSMutableAttributedString alloc] initWithString:label.text];
    [attributedText addAttribute:NSKernAttributeName
                           value:[NSNumber numberWithFloat:letterSpacing]
                           range:NSMakeRange(0, attributedText.length)];
    label.attributedText = attributedText;
}

[objective-c]UILabelの行間を設定

UILabelの行間を設定

-(void)setLineHeight:(UILabel*)label lineHeight:(float)lineHeight{
    NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init];
    paragrahStyle.minimumLineHeight = lineHeight;
    paragrahStyle.maximumLineHeight = lineHeight;
    NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:label.text];
    [attributedText addAttribute:NSParagraphStyleAttributeName
                           value:paragrahStyle
                           range:NSMakeRange(0, attributedText.length)];
    label.attributedText = attributedText;
}