-
CGPoint
- – location in space:{ x , y }
- – sometimes used as an origin
-
CGSize
– dimensions: { width , height }
-
CGRect
– location and dimension: { origin , size }
-
Example of creating a CGPoint
var point = CGPoint(x: 100.0, y: 200.0)
point.x = 300.0
point.y = 30.0
-
Example of creating a CGSize
var size = CGSize(width: 42.0, height: 11.0);
size.width = 100.0;
size.height = 72.0;
-
Example of creating a CGRect
var rect = CGRect (x:100.0, y: 200.0, width: 42.0,height: 11.0);
rect.origin.x = 0.0;
rect.size.width = 50.0
-
UIView Coordinate System: The origin is in the __?__ corner
upper left
-
UIView Coordinate System: y axis grows __?___
downwards
-
UIView Coordinate System: Units are __?__, not pixels
points
-
UIView Coordinate System: Points are units of __?__
coordinate system
-
UIView Coordinate System: Pixels are __?__ size unit of drawing
min size unit of drawing
-
UIView Coordinate System: Typically_?_ pixels per point
2 pixels per point
-
Location and Size: Two ways location and size are expressed.
(1) Frame is in superview’s coordinate system
(2)Bounds is in local coordinate system
-
Location and Size:__?__ is in superview’s coordinate system
Frame
-
Location and Size: __?__ is in local coordinate system
Bounds
-
Frame and Bounds: Use of one of these depends on ___?___
context
-
Frame and Bounds: If you are using a view, typically you use __?__.
frame
-
Frame and Bounds: If you are implementing a view, typically you use___?___
bounds
-
Frame and Bounds: Two examples of using a frame?
Creating a view, positioning a view in superview - use frame (perspective outside)
-
Frame and Bounds: Two examples of using bounds?
Handling events, drawing a view- use bounds (perspective inside)
-
Views: Are commonly placed in __?__
Storyboard
-
Views:Views are initialized using
UIView.init(frame: )
-
Manual Creation of a View; example:
let theFrame = CGRect(x:0, y:0, width:200, height:150);
let myView = UIView.init(frame: theFrame)
-
Manual Creation of a Label; example:
let frame = CGRect(x:20, y:45, width: 140, height: 20)
let myLabel = UILabel.init(frame: frame)
myLabel.text = “Hello Class”
-
Defining Custom Views: Three steps:
(1) Subclass UIView
(2) For custom drawing, you override: func drawRect(_ rect: CGRect)
(3) For event handling, you override: the touchesBegan, touchesMoved and touchesEnded function.
-
drawRect: Method: does nothing by default– If not overridden, then backgroundColor is used to fill(T/F).
TRUE
-
Override – drawRect: to draw a custom view – rect argument is __?__
area to draw
|
|