`

OC 学习备忘

    博客分类:
  • oc
 
阅读更多
1:居中布局

label.center = CGPointMake(CGRectGetMidX(window.bounds), CGRectGetMidY(window.bounds));

2:设备检测
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }

3:UISegmentedControl 组件
 NSArray *buttonNames = [NSArray arrayWithObjects:
                            @"One", @"Two", @"Three", @"Four", @"Five", @"Six", nil];
    UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
    segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segmentedControl.momentary = YES;
    [segmentedControl addTarget:self action:@selector(segmentAction:) 
               forControlEvents:UIControlEventValueChanged];

4:通过代码获取stroyBoard
NSString *sourceName = IS_IPAD ? @"Modal~iPad" : @"MySB";
    UIStoryboard *sb = [UIStoryboard storyboardWithName:sourceName bundle:[NSBundle mainBundle]];
    UINavigationController *navController = [sb instantiateViewControllerWithIdentifier:@"infoNavigationController”];

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics