live icons on ios
TRANSCRIPT
Live IconsMartin Kiss, PixelCut
@Tricertops
Images can be generatedCalendar as the first example from Apple
iOS 7 animates Clock icon Some icons are a lie
No APINo fun
Inside appsFun
Icons in UIKit• Tab Bar
• Navigation Bar and Toolbar
• Cell icons
• UIActivity icons
• more
Sources of information• Date, month, time, weekday
• Astronomy – moon phase, sunset, sunrise, season
• Location – country, continent, time zone
• Device Motion – compass, gyro, acceleration
• User Preferences – language, units, currency
• App Content – photos, names, dates, anything
No extra permissions
• Astronomy – needs only approximate location
• Location – detect using time zone or IP
• Device Motion – compass for magnetic north
ExamplesIn apps I made
Catalog of BooksTab with latest books shows date
Currency conversionShows symbol of last used currency
Notifications buttonShows status of the push notifications
User profileShows user’s photo if there is any
Geography appShows rank of country in UIActivity icon
Not limited to images
• Automatic night mode based on sunset
• Present optimized content based on country
• Pick correct Earth emoji 🌎🌍🌏 based on location
How togenerate images in code
How to generate
• UIView – set size, attributes, then capture snapshot
• CALayer – create directly or use view.layer
• CoreGraphics – elementary drawing calls
• PaintCode – visual editor that exports code
UIGraphicsBeginImageContextWithOptions(size, no, 0)
let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()
view.drawHierarchy(in: view.bounds, afterScreenUpdates: no)
UIGraphicsBeginImageContextWithOptions(size, no, 0)
let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()
view.layer.render(in: UIGraphicsGetCurrentContext()!)
UIGraphicsBeginImageContextWithOptions(size, no, 0)
let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()
let context = UIGraphicsGetCurrentContext()! UIColor.blue.setFill() context.fill(CGRect(x: 0, y: 0, width: 100, height: 100))
PaintCode is visualDraw the icon, bind parameters, export StyleKit class.
StyleKit.imageOfClock(seconds: 2400)
StyleKit.imageOfCompass(azimuth: 30)
StyleKit.imageOfMoon(phase: 0.1)
Only basic math is needed for these examples
Thank YouMartin Kiss, PixelCut
@Tricertops