iOS版 hello,world版本2
ios 版本 Hello World
2023-09-11 14:15:06 时间
// // main.m // Hello // // Created by lishujun on 14-8-28. // Copyright (c) 2014年 lishujun. All rights reserved. // #import <UIKit/UIKit.h> // 视图控制器对象 @interface HelloWorldViewController : UIViewController @end @implementation HelloWorldViewController -(void) loadView { //创建视图对象 UIView *contentView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]]; contentView.backgroundColor = [UIColor lightGrayColor]; self.view = contentView; //创建label对象 UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)]; label.text = @"Hello World"; label.center = contentView.center; // 垂直居中 label.textAlignment = UITextAlignmentCenter; // 水平居中 label.backgroundColor = [UIColor clearColor]; label.textColor = [UIColor redColor]; //在视图上添加label [contentView addSubview:label]; } @end // 委托对象 @interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> { IBOutlet UIWindow *window; } @property (nonatomic, retain) UIWindow *window; @property (nonatomic, retain) HelloWorldViewController *viewController; //window 必须声明为属性,声明为局部变量则无法绘制视图,显示为黑屏 //apple 官方文档把viewController也声明为属性了 @end @implementation HelloWorldAppDelegate @synthesize window; @synthesize viewController; -(void) applicationDidFinishLaunching:(UIApplication *)application { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]]; self.viewController = [[HelloWorldViewController alloc]init]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; } @end // 程序入口 int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, @"HelloWorldAppDelegate"); } }
相关文章
- iOS设计模式 - (2)UML类间关系精解
- iOS_7_scrollView大图缩放
- iOS版本APP全新上架啦
- Xamarin iOS教程之键盘的使用和设置
- iOS Simulator功能介绍关于Xamarin IOS开发
- 《iOS和tvOS 2D游戏开发教程》——第1章,第1.3节挑战
- 《iOS 6核心开发手册(第4版)》——1.11节秘诀:检测圆形
- iOS xcode8提交 iOS10 “此构建版本无效” (已解决)
- iOS 2D绘图详解(Quartz 2D)之阴影和渐变(Shadow,Gradient)
- iOS判断iPhone型号
- ios GUI系统综述:iOS的图形绘制、动画与runloop
- iOS动画的逻辑结构:动画的定义--动画是采用连续播放静止图像的方法产生物体运动的效果。
- iOS 10 的一个重要更新-线程竞态检测工具 Thread Sanitizer
- iOS 开发之 ReactiveCocoa(基础)
- 关于 iOS socket 都在这里了
- 一行代码实现iOS序列化与反序列化(runtime)
- 解决iOS安装包上传app store在构建版本处不显示、并收到报错:ITMS-90809: Deprecated API Usage - New apps that use UIWebView are no longer accepted的问题
- iOS开发UI篇—APP主流UI框架结构
- iOS 静态库制作(Xcode9.0 版本)(注:亲测.a静态文件放在Unity Plugins/IOS 也可用)
- weex-platform里iOS项目打包报错/platforms/ios/../../start does not exist.
- iOS开发 - 字面语法之数组注意事项
- iOS开发 - 若把上线版本下架,重新提交新的版本,通过审核后显示下架状态
- iOS开发 - Storyboard file 'MainStoryboard_iPad~ipad.storyboardc' was not found
- iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem