day1 视图编程入门
什么是UI
Command line DOS
User Interface 用户界面
iOS7.0 之后,扁平化
之前,拟物化
iOS7.0之后UI发生了扁平化的变化
iOS坐标体系
UI UIKit 是一个framework框架
1. UIWindow
2. UIView
UI前缀和命名空间
QF: { // QF命名空间
window
view
}
QF::window
QF::view
YuChuan : { // YuChuan命名空间
window
view
}
YuChuan::window
YuChuan::view
面试题:OC有命名空间吗,怎么解决的?
OC没有命名空间的概念
加前缀
UIView UI+View
NS NextStep
Foundation OC
UIKit iOS OC
AppKit MAC OC
为XCODE添加空模板
把空模板加入到模板文件夹中:
/Applications/Xcode6.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application
UIView
视图
main
principal class
delegate class
UIApplication是初始化程序的核心,它接受4个参数。
其中argc和argv两个参数来自于main()接受的两个参数;另外两个String型参数分别表示程序的主要类(principal class)和代理类(delegate class)。
如果主要类(principal class)为nil,则默认为UIApplication;如果代理类(delegate class)为nil,则程序假设程序的代理来自Main nib文件。如果这两个参数任意一个不为nil,则UIApplicationMain()函数则会根据参数创建相应的功能类。
因此,如果程序中使用自定义的UIApplication类的子类(不建议继承UIApplication类建立自定义的子类),你需要将你的自定义类名作为第3个参数传进来。
常用快捷键
新建项目
打开左侧pane: command + 0
旋转屏幕: Command + <-/->
截图: command + shift + 4 截图到桌面
command + shift + alt + 4 截图到剪切板
coomand + s 直接保存当前屏幕界面
退出正在运行的项目 在xcode中command+. 退出
或者在IPhone模拟器上,command + q 退出
home键
在command + shift + h
command + shift + hh 查看后台
刷新:
Product -> clean
command + shift + k
隐藏模拟器
Command+m 最小化到dock
或者隐藏 command+h (在文本编辑器中也可以) h: hide
把光标移动到行首行尾文件头文件尾
行首行尾:command+向左/向右箭头
文件头文件尾 :command + 上下箭头
应用程序的生命周期
当运行程序时:
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
按home键
applicationWillResignActive:
applicationDidEnterBackground:
程序从后台跑到前台
applicationWillEnterForeground:
applicationDidBecomeActive:
从后台删除
applicationDidEnterBackground:
applicationWillTerminate:
查看后台:
command + shift +hh(连续按两下h)
配置plist文件:
Application does not run in background : YES
按home键时:
applicationWillResignActive:
applicationWillTerminate:
配置plist文件:
Application does not run in background : YES
按home键时:
applicationWillResignActive:
applicationWillTerminate:
UIApplication图示
现有iOS设备
现有iOS设备坐标系
iPhone/iPod Touch
iphone1/3g/3gs iPod Touch1/2/3
像素 320 X 480 (0,0) (320, 480)
rect: (0, 0, 100, 50)
Retina屏
iphone4/4s
像素 640 X 960 (0,0) (320, 480)
iphone5/5c/5s
像素 640 X 1136 (0, 0) (320, 568)
iPhone6
像素 750X1334 (0,0) (375, 667)
iPhone6 Plus
像素 1242 X 2208 (0,0) (414,736)
iPad1/2/mini
像素 768 X 1024 (0, 0) (768, 1024)
new iPad, iPad4, air, mini2
像素 1536 X 2048 (0, 0)(768, 1024)
状态栏 20
UILabel
常用属性
text
backgroundColor
textAlignment
font
shadowColor
shadowOffset
lineBreakMode
numberOfLines
alpha
clipsToBounds (可以设置超过上个视图的话剪贴调)
subViews
tag
UIFont
font的斜体问题
// 拿到字体族的数组,数组中是字体族的名称
NSArray *familyArray = [UIFont familyNames];
for (NSString *familyName in familyArray) {
// 根据字体族的名称,拿到字体的名称
NSLog(@"----- %@ ------", familyName);
NSArray *names = [UIFont fontNamesForFamilyName:familyName];
for (NSString *fontName in names) {
NSLog(@"%@",fontName);
}
}
frame和bounds
frame是相对于父视图的坐标系而言,一个视图,
它的显示位置完全取决于其frame
View’s location and size expressed in two ways:
Frame is in terms of superview’s coordinate system
Bounds is in terms of local coordinate system
用UILabel显示象棋图:
@[@"车", @"马", @"象", @"王", @"后", @"象", @"马", @"车"];

作业:
UILabel显示9*9乘法表

什么是UI
Command line DOS
User Interface 用户界面
iOS7.0 之后,扁平化
之前,拟物化
iOS7.0之后UI发生了扁平化的变化
iOS坐标体系
UI UIKit 是一个framework框架
1. UIWindow
2. UIView
UI前缀和命名空间
QF: { // QF命名空间
window
view
}
QF::window
QF::view
YuChuan : { // YuChuan命名空间
window
view
}
YuChuan::window
YuChuan::view
面试题:OC有命名空间吗,怎么解决的?
OC没有命名空间的概念
加前缀
UIView UI+View
NS NextStep
Foundation OC
UIKit iOS OC
AppKit MAC OC
为XCODE添加空模板
把空模板加入到模板文件夹中:
/Applications/Xcode6.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application
UIView
视图
main
principal class
delegate class
UIApplication是初始化程序的核心,它接受4个参数。
其中argc和argv两个参数来自于main()接受的两个参数;另外两个String型参数分别表示程序的主要类(principal class)和代理类(delegate class)。
如果主要类(principal class)为nil,则默认为UIApplication;如果代理类(delegate class)为nil,则程序假设程序的代理来自Main nib文件。如果这两个参数任意一个不为nil,则UIApplicationMain()函数则会根据参数创建相应的功能类。
因此,如果程序中使用自定义的UIApplication类的子类(不建议继承UIApplication类建立自定义的子类),你需要将你的自定义类名作为第3个参数传进来。
常用快捷键
新建项目
打开左侧pane: command + 0
旋转屏幕: Command + <-/->
截图: command + shift + 4 截图到桌面
command + shift + alt + 4 截图到剪切板
coomand + s 直接保存当前屏幕界面
退出正在运行的项目 在xcode中command+. 退出
或者在IPhone模拟器上,command + q 退出
home键
在command + shift + h
command + shift + hh 查看后台
刷新:
Product -> clean
command + shift + k
隐藏模拟器
Command+m 最小化到dock
或者隐藏 command+h (在文本编辑器中也可以) h: hide
把光标移动到行首行尾文件头文件尾
行首行尾:command+向左/向右箭头
文件头文件尾 :command + 上下箭头
应用程序的生命周期
当运行程序时:
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
按home键
applicationWillResignActive:
applicationDidEnterBackground:
程序从后台跑到前台
applicationWillEnterForeground:
applicationDidBecomeActive:
从后台删除
applicationDidEnterBackground:
applicationWillTerminate:
查看后台:
command + shift +hh(连续按两下h)
配置plist文件:
Application does not run in background : YES
按home键时:
applicationWillResignActive:
applicationWillTerminate:
配置plist文件:
Application does not run in background : YES
按home键时:
applicationWillResignActive:
applicationWillTerminate:
UIApplication图示
现有iOS设备
现有iOS设备坐标系
iPhone/iPod Touch
iphone1/3g/3gs iPod Touch1/2/3
像素 320 X 480 (0,0) (320, 480)
rect: (0, 0, 100, 50)
Retina屏
iphone4/4s
像素 640 X 960 (0,0) (320, 480)
iphone5/5c/5s
像素 640 X 1136 (0, 0) (320, 568)
iPhone6
像素 750X1334 (0,0) (375, 667)
iPhone6 Plus
像素 1242 X 2208 (0,0) (414,736)
iPad1/2/mini
像素 768 X 1024 (0, 0) (768, 1024)
new iPad, iPad4, air, mini2
像素 1536 X 2048 (0, 0)(768, 1024)
状态栏 20
UILabel
常用属性
text
backgroundColor
textAlignment
font
shadowColor
shadowOffset
lineBreakMode
numberOfLines
alpha
clipsToBounds (可以设置超过上个视图的话剪贴调)
subViews
tag
UIFont
font的斜体问题
// 拿到字体族的数组,数组中是字体族的名称
NSArray *familyArray = [UIFont familyNames];
for (NSString *familyName in familyArray) {
// 根据字体族的名称,拿到字体的名称
NSLog(@"----- %@ ------", familyName);
NSArray *names = [UIFont fontNamesForFamilyName:familyName];
for (NSString *fontName in names) {
NSLog(@"%@",fontName);
}
}
frame和bounds
frame是相对于父视图的坐标系而言,一个视图,
它的显示位置完全取决于其frame
View’s location and size expressed in two ways:
Frame is in terms of superview’s coordinate system
Bounds is in terms of local coordinate system
用UILabel显示象棋图:
@[@"车", @"马", @"象", @"王", @"后", @"象", @"马", @"车"];

作业:
UILabel显示9*9乘法表