SlideShare a Scribd company logo
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

이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
devCAT Studio, NEXON
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
henjeon
 
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
MinGeun Park
 
WebRTC multistream
WebRTC multistreamWebRTC multistream
WebRTC multistream
mganeko
 

What's hot (20)

Multibranch pipelineでいろいろ学んだこと
Multibranch pipelineでいろいろ学んだことMultibranch pipelineでいろいろ学んだこと
Multibranch pipelineでいろいろ学んだこと
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
 
이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
이승재, 강성훈, 내가 만든 언어의 개발환경을 Visual Studio Code로 빠르고 쉽게 구축하기 #1, NDC2017
 
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
 
【Unite Tokyo 2018 Training Day】ProBuilderで学ぶレベルデザイン ProBuilderをマスターしよう!
【Unite Tokyo 2018 Training Day】ProBuilderで学ぶレベルデザイン ProBuilderをマスターしよう!【Unite Tokyo 2018 Training Day】ProBuilderで学ぶレベルデザイン ProBuilderをマスターしよう!
【Unite Tokyo 2018 Training Day】ProBuilderで学ぶレベルデザイン ProBuilderをマスターしよう!
 
Docker for Windows & Web Apps for Containers 実践活用技法
Docker for Windows & Web Apps for Containers 実践活用技法Docker for Windows & Web Apps for Containers 実践活用技法
Docker for Windows & Web Apps for Containers 実践活用技法
 
PostgreSQL画像データ収集・格納
PostgreSQL画像データ収集・格納PostgreSQL画像データ収集・格納
PostgreSQL画像データ収集・格納
 
【CEDEC2018】一歩先のUnityでのパフォーマンス/メモリ計測、デバッグ術
【CEDEC2018】一歩先のUnityでのパフォーマンス/メモリ計測、デバッグ術【CEDEC2018】一歩先のUnityでのパフォーマンス/メモリ計測、デバッグ術
【CEDEC2018】一歩先のUnityでのパフォーマンス/メモリ計測、デバッグ術
 
良い?悪い?コードコメントの書き方
良い?悪い?コードコメントの書き方良い?悪い?コードコメントの書き方
良い?悪い?コードコメントの書き方
 
[DO02] Jenkins PipelineとBlue Oceanによる、フルスクラッチからの継続的デリバリ
[DO02] Jenkins PipelineとBlue Oceanによる、フルスクラッチからの継続的デリバリ[DO02] Jenkins PipelineとBlue Oceanによる、フルスクラッチからの継続的デリバリ
[DO02] Jenkins PipelineとBlue Oceanによる、フルスクラッチからの継続的デリバリ
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
 
JPUGしくみ+アプリケーション勉強会(第20回)
JPUGしくみ+アプリケーション勉強会(第20回)JPUGしくみ+アプリケーション勉強会(第20回)
JPUGしくみ+アプリケーション勉強会(第20回)
 
CPUから見たG1GC
CPUから見たG1GCCPUから見たG1GC
CPUから見たG1GC
 
【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現
 
Qtではじめるクロスプラットフォームアプリケーション開発 osc2019 Nagoya
Qtではじめるクロスプラットフォームアプリケーション開発 osc2019 NagoyaQtではじめるクロスプラットフォームアプリケーション開発 osc2019 Nagoya
Qtではじめるクロスプラットフォームアプリケーション開発 osc2019 Nagoya
 
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
 
Linqの速度測ってみた
Linqの速度測ってみたLinqの速度測ってみた
Linqの速度測ってみた
 
GitLab CI/CD パイプライン
GitLab CI/CD パイプラインGitLab CI/CD パイプライン
GitLab CI/CD パイプライン
 
コンテナとimmutableとわたし。あとセキュリティ。(Kubernetes Novice Tokyo #15 発表資料)
コンテナとimmutableとわたし。あとセキュリティ。(Kubernetes Novice Tokyo #15 発表資料)コンテナとimmutableとわたし。あとセキュリティ。(Kubernetes Novice Tokyo #15 発表資料)
コンテナとimmutableとわたし。あとセキュリティ。(Kubernetes Novice Tokyo #15 発表資料)
 
WebRTC multistream
WebRTC multistreamWebRTC multistream
WebRTC multistream
 

Similar to Implementing CATiledLayer

iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
NascentDigital
 
Rails and iOS with RestKit
Rails and iOS with RestKitRails and iOS with RestKit
Rails and iOS with RestKit
Andrew Culver
 
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
ESUG
 

Similar to Implementing CATiledLayer (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
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
 
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
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android os
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
Synapse india mobile apps update
Synapse india mobile apps updateSynapse india mobile apps update
Synapse india mobile apps update
 
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
 

More from Jesse Collis (6)

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
 
A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013
 
Epic Refactorings - Melbourne Cocoaheads June 2011
Epic Refactorings - Melbourne Cocoaheads June 2011Epic Refactorings - Melbourne Cocoaheads June 2011
Epic Refactorings - Melbourne Cocoaheads June 2011
 
CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012
 
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
 
Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Implementing CATiledLayer

  • 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