Ios: Core Graphics and Core Animation: Tommy Macwilliam
Ios: Core Graphics and Core Animation: Tommy Macwilliam
Announcements
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Today
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Quartz
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Context
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGPathCloseSubpath: close path CGContextAddPath: add path to context CGContextFillPath: create shape from path CGContextStrokePath: create outline from path
Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGContextSetLineWidth: set stroke weight CGContextSetLineCap: set how lines end CGContextSetLineDash: draw dotted line CGContextSetStrokeColorWithColor: set color (UIColors have property for CGColor)
Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
Shadows
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Saving State
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGContextSaveGState: push state onto stack CGContextRestoreGState: pop value off stack
example time!
Gradients
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Color Spaces
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGColorSpaceCreateDeviceRGB(): RGB (red, green, blue) CGColorSpaceCreateDeviceCMYK(): CMYK (cyan, magenta, yellow, key) CGColorSpaceCreateDeviceGray(): grayscale
Gradients
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
Custom Views
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
drawRect is a method of any UIView subclass UIView, UIButton, etc. to create custom views
Custom Views
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
UIImageView
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
UIImagePickerController
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
modal view controller allowing for selection of image from library sourceType: where to get images from presentModalViewController (just like any other view controller) to display
UIImagePickerControllerDelegate
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
make sure to set delegate property! imagePickerController:didFinish PickingMediaWithInfo: user selected image
can get UIImagePickerControllerEditedImage or UIImagePickerControllerOriginalImage from passed dictionary
Image Picker
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
UIImage
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
UIImage ready to use with Core Graphics via CGImage drawInRect: draw UIImage in given CGRect CGContextDrawImage: draw CGImage in given CGRect
different coordinate system, so image will be upside-down!
Transforms
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGContextRotateCTM: rotate about a point CGContextScaleCTM: change size CGContextTranslateCTM: move in a direction
Clipping
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
rectangles are boring! remember CGMutablePathRef? CGContextClip restricts all drawings to last path
UIImage
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
Core Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
animate 2D layers in 3D space implicit: set new properties, get smooth animation explicit: full control over timing, etc.
Core Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Implicit Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
static methods to UIViews set animation properties enclosed in beginAnimations:context: and commitAnimation changed properties will animate automatically
Implicit Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
setAnimationTransition: lots of stock animations built in setAnimationDuration: time, in seconds, of animation setAnimationDelegate, setAnimationDidStopSelector: register callbacks
Implicit Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
Layers
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
Keyframe Animation
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CAKeyframeAnimation creates a custom animation key path species what property will be animated
animatable properties: http://developer.apple. com/library/ios/#documentation/Cocoa/ Conceptual/CoreAnimation_guide/Articles/ AnimProps.html
Animation Paths
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CGMutablePathRef again! path species path layer can be animated along (position keypath) duration for animation in seconds
Transforms
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
CATransform3DMakeRotation: rotation matrix CATransform3DMakeScale: scaling matrix CATransform3DMakeTranslation: translation matrix values gives NSArray of frames
Keyframe Animations
iOS: Core Graphics and Core Animation Tommy MacWilliam Core Graphics Drawing Working with Images Core Animation Integrating with Other Apps
example time!
just like Android, other apps opened via URLs [[UIApplication sharedApplication] openURL:url]
where url is an NSURL (schemes like http://, tel:, sms:)
specify your own URLs with <app name>-Info.plist (like AndroidManifest.xml) application:handleOpenURL: red when app opened from URL
example time!