下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
@interface AppDelegate() @property UILabel* show; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; //创建一个UIViewController 对象 UIViewController* controller = [[UIViewController alloc] init]; //让该程序的窗口加载并显示 viewController 视图控制器关联的用户界面 self.window.rootViewController = controller; //创建一个UIView 对象 UIView* rootView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //设置 controller 显示 rootView 控件 controller.view = rootView; //创建一个圆角按钮 UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; //设置按钮的大小 button.frame = CGRectMake(120,100,80,40); //为按钮设置文本 [button setTitle:@"确定" forState:UIControlStateNormal]; //将按钮添加到 rootView 控件中 [rootView addSubview:button]; //创建一个 UILabel 对象 self.show = [[UILabel alloc] initWithFrame:CGRectMake(60,40,180,30)]; // UILabel* show = [[UILabel alloc] initWithFrame:CGRectMake(60,30)]; //将UILabel 添加到 rootView 控件中 [rootView addSubview: self.show]; //设置 UILabel 默认显示的文本 self.show.text = @"初始文本"; self.show.backgroundColor = [UIColor grayColor]; //为圆角按钮的触碰事件绑定事件处理方法 [button addTarget:self action:@selector(clickHandler:) forControlEvents:UIControlEventTouchUpInside]; //将该 UIWindow 对象设为主窗口并显示出来 [self.window makeKeyAndVisible]; return YES; }
- (void)clickHandler:(id)sender { self.show.text = @"开始学习 IOS 吧!"; }
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。