SlideShare a Scribd company logo
1 of 24
CATiledLayer


Jesse Collis, Melbourne Cocoaheads, February 2012
       jesse@jcmultimedia.com.au / @sirjec
CATiledLayer
Tiled Views in 2009

           Tiled UIScrollViews

           iOS 3 Compatibility

                @2x.png
CATiledLayer in iOS4
My main goals

• CATiledLayer in a zooming scrollView
• Seamless integration into iOS4+
• Seamless integration between retina / non-
  retina screens
• provide only one sized tile (not @2x)
Success
Finally...
Success
Finally...
Here’s what I learnt
• UIViews are backed by CALayers
• All good CALayer documentation is OSX
  based
• NSView is not backed by CALayer
• drawRect: (more or less) equals
  drawLayer:inContext delegate method in
  OSX docs
What I learnt cont...
• Core Graphics helps with high resolution
  screens most of the time

• CATiledLayer is just a CALayer subclass
 • It’s instantiated as a UIView’s layer
 • It uses drawRect:
 • contentScale is set by it’s UIView
Basic Implementation
+(Class)layerClass
{
  return [CATiledLayer class];
}

- (id)initWithFrame:(CGRect)frame
{
  ...
  [(CATiledLayer *)self.layer setLevelsOfDetail:1];
  [(CATiledLayer *)self.layer setLevelsOfDetailBias:3];
  ...
}

- (void)drawRect:(CGRect)rect
{
  CGContextRef c = UIGraphicsGetCurrentContext();
  CGFloat scale = CGContextGetCTM(c).a;

    NSInteger col = (CGRectGetMinX(rect) * scale) / self.tileSize.width;
    NSInteger row = (CGRectGetMinY(rect) * scale) / self.tileSize.height;

    UIImage *tile_image = [self.tileSource tiledView:self
                                         imageForRow:row
                                    column:col scale:scale];
    [tile_image drawInRect:rect];
}
LOD & LODB

• LOD is the number of levels it will ask you
  for as you zoom out
• LODB is the number of levels it will use as
  you zoom in
UIScrollView zoomScale vs.
         CATiledLayer LODB


• zoomScale is measured on a linear scale
• zoomScale has an exponential effect on
  pixels
• Each LODB/LOD is a power of two more
  or less than the previous level of detail.
UIScrollView zoomScale vs.
         CATiledLayer LODB


• zoomScale is measured on a linear scale
• zoomScale has an exponential effect on
  pixels
• Each LODB/LOD is a power of two more
  or less than the previous level of detail.
Some Notes
• Setting LOD and LODB to 0 causes a blank
  view
• Setting LOD and LODB to 1 seems to be
  undefined behaviour
• Setting LOD to 1, and LODB > 1 is fine,
  but I like to set LOD to 0 if I’m using
  LODB.
Code Time




JCTiledLayer
Retina Display
Apple’s docs on Supporting High Resolution screens:

[You] may need to adjust [Core Animation Layers] drawing code to account for
scale factors. Normally, when you draw in your view’s drawRect: method … of
the layer’s delegate, the system automatically adjusts the graphics context to
account for scale factors. However, knowing or changing that scale factor
might still be necessary when your view does one of the following:

 • Creates additional Core Animation layers with different scale factors and
   composites them into its own content.
A few things you need to do
•   layer.contentsScale == 2 so everything in pixel land
    is squared

•   Multiply the original tileSize by the contentsScale

•   Multiply drawRect: rect by the context scale giving
    us our 512x512 tileSize

•   divide rect by contentsScale to give us rect with
    256x256 dimensions

•   rect origin can now be used to grab the right tile

•   draw said tile it into rect; Core Graphics will do
    the rest
What’s next

• Add UIGestureRecognizer support for
  more map-like features
• Overlay support
• Replace UIImages with vectors or SVG
  drawing
JCTiledView is on
     Github


     •   github.com/jessedc/JCTiledScrollView
Thanks!

Jesse Collis
jesse@jcmultimedia.com.au
twitter.com/sirjec

More Related Content

What's hot

[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView
[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView
[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListViewKobkrit Viriyayudhakorn
 
Sergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingSergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingFlash Conference
 
WebGL Fundamentals
WebGL FundamentalsWebGL Fundamentals
WebGL FundamentalsSencha
 
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenCreating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenUnity Technologies
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012philogb
 
Getting started with open gl es 2
Getting started with open gl es 2Getting started with open gl es 2
Getting started with open gl es 2matthewgalaviz
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説Unity Technologies Japan K.K.
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's NewNascentDigital
 
The Power of WebGL - Hackeando sua GPU com JavaScript
The Power of WebGL - Hackeando sua GPU com JavaScriptThe Power of WebGL - Hackeando sua GPU com JavaScript
The Power of WebGL - Hackeando sua GPU com JavaScriptRaphael Amorim
 
OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationphilogb
 

What's hot (16)

Responsiveness
ResponsivenessResponsiveness
Responsiveness
 
Diagrams, Xtext and UX
Diagrams, Xtext and UXDiagrams, Xtext and UX
Diagrams, Xtext and UX
 
Xtext, diagrams and ux
Xtext, diagrams and uxXtext, diagrams and ux
Xtext, diagrams and ux
 
[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView
[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView
[React Native Tutorial] Lecture 7: Navigation - Scene Transition - ListView
 
Sergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingSergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with Starling
 
ProjectsSummary
ProjectsSummaryProjectsSummary
ProjectsSummary
 
WebGL Fundamentals
WebGL FundamentalsWebGL Fundamentals
WebGL Fundamentals
 
Graphical Views For Xtext
Graphical Views For XtextGraphical Views For Xtext
Graphical Views For Xtext
 
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenCreating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
 
Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012Leaving Flatland: Getting Started with WebGL- SXSW 2012
Leaving Flatland: Getting Started with WebGL- SXSW 2012
 
Getting started with open gl es 2
Getting started with open gl es 2Getting started with open gl es 2
Getting started with open gl es 2
 
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説【Unite 2017 Tokyo】Unity5.6での2D新機能解説
【Unite 2017 Tokyo】Unity5.6での2D新機能解説
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
 
Scenejs
ScenejsScenejs
Scenejs
 
The Power of WebGL - Hackeando sua GPU com JavaScript
The Power of WebGL - Hackeando sua GPU com JavaScriptThe Power of WebGL - Hackeando sua GPU com JavaScript
The Power of WebGL - Hackeando sua GPU com JavaScript
 
OpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualizationOpenVisConf - WebGL for graphics and data visualization
OpenVisConf - WebGL for graphics and data visualization
 

Viewers also liked

Monitoraggio programmi tv e video (Italian)
Monitoraggio programmi tv e video (Italian)Monitoraggio programmi tv e video (Italian)
Monitoraggio programmi tv e video (Italian)Jesse Gosse
 
Media studies
Media studiesMedia studies
Media studiesTeri23
 
Preparing for iOS 9 - Melbourne Cocoaheads June 2015
Preparing for iOS 9 - Melbourne Cocoaheads June 2015Preparing for iOS 9 - Melbourne Cocoaheads June 2015
Preparing for iOS 9 - Melbourne Cocoaheads June 2015Jesse Collis
 
Apps para comprar y vender
Apps para comprar y venderApps para comprar y vender
Apps para comprar y venderDUPLOGRAFIC
 

Viewers also liked (7)

Social Media Marketing
Social Media MarketingSocial Media Marketing
Social Media Marketing
 
Installation Arts ╳ concept
Installation Arts ╳ conceptInstallation Arts ╳ concept
Installation Arts ╳ concept
 
Monitoraggio programmi tv e video (Italian)
Monitoraggio programmi tv e video (Italian)Monitoraggio programmi tv e video (Italian)
Monitoraggio programmi tv e video (Italian)
 
Media studies
Media studiesMedia studies
Media studies
 
Preparing for iOS 9 - Melbourne Cocoaheads June 2015
Preparing for iOS 9 - Melbourne Cocoaheads June 2015Preparing for iOS 9 - Melbourne Cocoaheads June 2015
Preparing for iOS 9 - Melbourne Cocoaheads June 2015
 
magazine1
magazine1magazine1
magazine1
 
Apps para comprar y vender
Apps para comprar y venderApps para comprar y vender
Apps para comprar y vender
 

Similar to CATiledLayer: Tiled Views in iOS

Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextMugunth Kumar
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: IntroductionInnerFood
 
The Great CALayer Tour
The Great CALayer TourThe Great CALayer Tour
The Great CALayer TourScott Gardner
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJSFestUA
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAmir Barylko
 
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your ApplicationsThe Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your Applicationsbalassaitis
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best PracticesJean-Luc David
 
Rails and iOS with RestKit
Rails and iOS with RestKitRails and iOS with RestKit
Rails and iOS with RestKitAndrew Culver
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGLGary Yeh
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform AppsFITC
 
From Legacy Database to Domain Layer Using a New Cincom VisualWorks Tool
From Legacy Database to Domain Layer Using a New Cincom VisualWorks ToolFrom Legacy Database to Domain Layer Using a New Cincom VisualWorks Tool
From Legacy Database to Domain Layer Using a New Cincom VisualWorks ToolESUG
 
MongoDB Charts Meetup - 7-24-2018
MongoDB Charts Meetup - 7-24-2018MongoDB Charts Meetup - 7-24-2018
MongoDB Charts Meetup - 7-24-2018Jay Gordon
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshopStacy Goh
 

Similar to CATiledLayer: Tiled Views in iOS (20)

Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreText
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: Introduction
 
The Great CALayer Tour
The Great CALayer TourThe Great CALayer Tour
The Great CALayer Tour
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-Native
 
Core animation
Core animationCore animation
Core animation
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
 
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your ApplicationsThe Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
 
Cocos2d for beginners
Cocos2d for beginnersCocos2d for beginners
Cocos2d for beginners
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
 
Rails and iOS with RestKit
Rails and iOS with RestKitRails and iOS with RestKit
Rails and iOS with RestKit
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
From Legacy Database to Domain Layer Using a New Cincom VisualWorks Tool
From Legacy Database to Domain Layer Using a New Cincom VisualWorks ToolFrom Legacy Database to Domain Layer Using a New Cincom VisualWorks Tool
From Legacy Database to Domain Layer Using a New Cincom VisualWorks Tool
 
IOS Storyboards
IOS StoryboardsIOS Storyboards
IOS Storyboards
 
MongoDB Charts Meetup - 7-24-2018
MongoDB Charts Meetup - 7-24-2018MongoDB Charts Meetup - 7-24-2018
MongoDB Charts Meetup - 7-24-2018
 
COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshop
 
Svcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobileSvcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobile
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

CATiledLayer: Tiled Views in iOS

  • 1. CATiledLayer Jesse Collis, Melbourne Cocoaheads, February 2012 jesse@jcmultimedia.com.au / @sirjec
  • 3. Tiled Views in 2009 Tiled UIScrollViews iOS 3 Compatibility @2x.png
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. My main goals • CATiledLayer in a zooming scrollView • Seamless integration into iOS4+ • Seamless integration between retina / non- retina screens • provide only one sized tile (not @2x)
  • 12. Here’s what I learnt • UIViews are backed by CALayers • All good CALayer documentation is OSX based • NSView is not backed by CALayer • drawRect: (more or less) equals drawLayer:inContext delegate method in OSX docs
  • 13. What I learnt cont... • Core Graphics helps with high resolution screens most of the time • CATiledLayer is just a CALayer subclass • It’s instantiated as a UIView’s layer • It uses drawRect: • contentScale is set by it’s UIView
  • 14. Basic Implementation +(Class)layerClass { return [CATiledLayer class]; } - (id)initWithFrame:(CGRect)frame { ... [(CATiledLayer *)self.layer setLevelsOfDetail:1]; [(CATiledLayer *)self.layer setLevelsOfDetailBias:3]; ... } - (void)drawRect:(CGRect)rect { CGContextRef c = UIGraphicsGetCurrentContext(); CGFloat scale = CGContextGetCTM(c).a; NSInteger col = (CGRectGetMinX(rect) * scale) / self.tileSize.width; NSInteger row = (CGRectGetMinY(rect) * scale) / self.tileSize.height; UIImage *tile_image = [self.tileSource tiledView:self imageForRow:row column:col scale:scale]; [tile_image drawInRect:rect]; }
  • 15. LOD & LODB • LOD is the number of levels it will ask you for as you zoom out • LODB is the number of levels it will use as you zoom in
  • 16. UIScrollView zoomScale vs. CATiledLayer LODB • zoomScale is measured on a linear scale • zoomScale has an exponential effect on pixels • Each LODB/LOD is a power of two more or less than the previous level of detail.
  • 17. UIScrollView zoomScale vs. CATiledLayer LODB • zoomScale is measured on a linear scale • zoomScale has an exponential effect on pixels • Each LODB/LOD is a power of two more or less than the previous level of detail.
  • 18. Some Notes • Setting LOD and LODB to 0 causes a blank view • Setting LOD and LODB to 1 seems to be undefined behaviour • Setting LOD to 1, and LODB > 1 is fine, but I like to set LOD to 0 if I’m using LODB.
  • 20. Retina Display Apple’s docs on Supporting High Resolution screens: [You] may need to adjust [Core Animation Layers] drawing code to account for scale factors. Normally, when you draw in your view’s drawRect: method … of the layer’s delegate, the system automatically adjusts the graphics context to account for scale factors. However, knowing or changing that scale factor might still be necessary when your view does one of the following: • Creates additional Core Animation layers with different scale factors and composites them into its own content.
  • 21. A few things you need to do • layer.contentsScale == 2 so everything in pixel land is squared • Multiply the original tileSize by the contentsScale • Multiply drawRect: rect by the context scale giving us our 512x512 tileSize • divide rect by contentsScale to give us rect with 256x256 dimensions • rect origin can now be used to grab the right tile • draw said tile it into rect; Core Graphics will do the rest
  • 22. What’s next • Add UIGestureRecognizer support for more map-like features • Overlay support • Replace UIImages with vectors or SVG drawing
  • 23. JCTiledView is on Github • github.com/jessedc/JCTiledScrollView

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n