Please note, this blog entry is from a previous course. You might want to check out the current one.
Lecture #6 covers views and gestures and shows how to use them in a extensive demo at the end of the lecture:
The hierarchy of views is most often constructed in storyboard but it can be done also:
- (void)addSubview:(UIView*)aView; - (void)removeFromSuperview;
A view can be accessed from a view controller using its:
@property (strong, nonatomic) UIView *view
View coordinates and dimensions are defined as CGFloat, CGPoint, CGSize, and CGRect. The coordinate system start in the left top corner and uses points not pixels. (contentScaleFactor holds their relation)
… use bounds for drawing and frames for positioning.
… custom views are used to for custom drawing by overriding drawRect:, which is called by the system. If it needs to be redrawn, call setNeedsDisplay: For the actual drawing C functions are used to access the drawing context.
Gestures are handled by the UIGestureRecognizer, which can activate standard or custom handlers.
Slides are available on iTunes …..
The lecture is available at iTunes and is named “6. Views and Gestures (January 24, 2013)”.