IOS开发(55)之为普通App添加Storyboard

1 前言

如果我们原来的项目中没有Storyboard,不要着急,我们今天就来教你如何添加Storyboard。

2 代码实例

2.1 在原来项目中新建一个Storyboard


2.2 选择设备类型


2.3 设置Storyboard的名称


2.4 在AddStoryboardTest-Info.plist中添加节点   UIMainStoryboardFile 值为Storyboard的名字:iPhone


2.5 在Storyboard中添加View视图,并将其Class设置为已有的Controller的名字


ZYViewController.h

#import <UIKit/UIKit.h>

@interface ZYViewController : UIViewController

@property(nonatomic,strong) UILabel *myLabel;

@end

ZYViewController.m

@synthesize myLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    //    CGRect labelFrame = CGRectMake(0.0f, 0.0f, 100.0f, 23.0f);
    CGRect labelFrame = CGRectMake(0.0f, 0.0f, 100.0f, 50.0f);
    self.myLabel = [[UILabel alloc] initWithFrame:labelFrame];
    self.myLabel.numberOfLines = 3;//分三行
    self.myLabel.text = @"Archy is Studying IOS 5 Programming";//label的文字
    self.myLabel.font = [UIFont boldSystemFontOfSize:14.0f];//字体样式
    self.myLabel.center = self.view.center;//UILabel控件居中
    [self.view addSubview:self.myLabel];
}

运行结果


3 结语

以上就是所有内容,希望对大家有所帮助。

Demo添加前:http://download.csdn.net/detail/u010013695/5348863

Demo添加后:http://download.csdn.net/detail/u010013695/5348867

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值