iOS Property List and Views学习笔记(Lesson 5)

来源:互联网 发布:淘宝店铺扣48分 编辑:程序博客网 时间:2024/06/16 20:54

斯坦福课程(Developing iOS 8 Apps with Swift),lesson 5


1、CGFloat: Always use this instead ofDouble or Float for anything to do with a UIView's coordinate system.

可以与Float,Double转换:varcfg = CGFloat(aDouble)


2、NSString is bridged to String.(String is struct )

   NSArray is bridged to Array<Anyobject>

   NSDictionary is bridged toDictionary<NSObject, Anyobject>


3、Property List is really just thedefinition of a term.

 

4、A view, a subclass of the class UIViewin iOS represents a rectangular area on the screen.

 

5、A UIViews' initializer is different ifit comes out of a storyboard.

Init(frame: CGRect) //initializer if the UIView is created in code

Init(coder: NSCoder) //initializer if the UIView comes out of astoryboard

 

6、If you need an initializer, implementthem both

Implement T:

 

func setup() {…}

 

override init(frame: CGRect) {

super.init(frame: frame)

setup()

}

 

required override init(coder aDecoder: NSCoder) {

super.init(coder: aDecoder)

setup()

}

 

7、 Origin is upper left.

Units are points, not pixels.

Most of the time there are 2 pixels per point, but it could be only1 or something else

How many pixels per point are there?   UIView's var contentScalaFactor: CGFloat

It will return the number of pixels per point.

 

8、 frame and center, which are aboutposition, bounce which is your size and area that you're drawing into your owncoordinate system. (frame center 用来定位视图的, bounds 用来在视图自身的坐标系中确定大小和区域的)



0 0