您的位置:首页 > 产品设计 > UI/UE

UI_UINib

2016-07-13 16:56 357 查看
//

//  ViewController.m

//  UINib

//

//  Created by HarrySun on 16/7/13.

//  Copyright © 2016年 Mobby. All rights reserved.

//

#import "ViewController.h"

#import "SecondViewController.h"

@interface
ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

    [superviewDidLoad];

    

    // 使用nib获取View(xib)
这边NibNamed是xib中的Class名字 

    NSArray *nib = [[NSBundlemainBundle]
loadNibNamed:@"MyView"owner:selfoptions:nil];

    UIView *tempView = [nibobjectAtIndex:0];

    CGRect tempFrame = [[UIScreenmainScreen]
bounds];

    [tempView setCenter:CGPointMake(tempFrame.size.width
/ 2, tempFrame.size.height /2)];

    [self.viewaddSubview:tempView];

    

    

    

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent
*)event{

    

    // 使用nib获取ViewController(xib)SecondViewController是利用xib创建的一个ViewController,上面随便放了一些东西

    SecondViewController *secondVC = [[SecondViewControlleralloc]initWithNibName:@"SecondViewController"bundle:nil];

    [self.navigationControllerpushViewController:secondVCanimated:YES];

    

}

- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UINib UI