SlideShare uma empresa Scribd logo
1 de 9
Presenter Intro.
IBDesignable and IBInspectable
By: Gagan Vishal Mishra
Introduction
IBDesignable & IBInspectable
2
• In Xcode 6, Apple has introduced the live rendering feature of Interface Builder
that allows developer to design and inspect a custom view on the Interface
Builder canvas.
• This feature provides ability to preview and modify custom components at design
time via @IBDesignable and @IBInspectable.
• IBDesignable and IBInspectable are related to each other, first one applies to the
class definition, the second one applies to the properties.
• Every time you open the Interface Builder, Xcode quickly compiles the nib. This
uses the initializers and the drawing methods to update the xib/storyboard in real
time.
IBDesignable
IBDesignable & IBInspectable
3
• Prefixing class with the @IBDesignable keyword to inform Interface Builder that
the class instances will try to design themselves when added to the storyboard.
• Adding a class with the @IBDesignable keyword allows compiler that any
problems can be debugged without compiling and running the whole project. To
kick off a debugging session right in place
1. Simply set a breakpoint in your code.
2. Select the view in Interface Builder.
3. Choose Editor ➔ Debug Selected Views.
IBDesignable
IBDesignable & IBInspectable
4
IBDesignable uses the initializers and the drawing methods to update the
xib/storyboard in real time. IBDesignable attribute can be added to the class
declaration, class extension, or category for a custom view. It can be added as below
Objective-C
IB_DESIGNABLE
@interface YourView: UIView
Swift
@IBDesignable
class YourView: UIView
IBDesignable
IBDesignable & IBInspectable
5
Some time the custom view won’t have the full data of the app when rendered in
Interface Builder, we may need to generate the data later for displaying in view e.g.
user image from server etc. There are two ways to implement it
1.prepareForInterfaceBuilder() : compiles with the rest of your code but is only
executed when your view is being prepared for display in Interface Builder.
2.TARGET_INTERFACE_BUILDER: Add run time condition check
#if !TARGET_INTERFACE_BUILDER
// this code will run in the app itself
#else
// this code will execute only in IB
#endif
IBInspectable
IBDesignable & IBInspectable
6
• Prefixing any properties of the class with @IBInspectable, we ensure that
Interface Builder can read and write the value of these properties directly in the
inspector view.
• These properties will allow you to change the outlet class in real time.
• Properties can be created as below
Objective-C
@property (nonatomic) IBInspectable
Type * yourVariable;
Swift
@IBInspectable var yourVariable: Type()
=Type()
IBInspectable
IBDesignable & IBInspectable
7
• Only a limited data types can be set to IBInspectable
1. Int
2. CGFloat
3. Double
4. String
5. Bool
6. CGPoint
7. CGSize
8. CGRect
9. UIColor
10. UIImage
IBInspectable
IBDesignable & IBInspectable
8
• Making Existing Types Inspectable: Built-in Cocoa types can also be extended to
have inspectable properties beyond the ones already in Interface Builder’s
attribute inspector. If you like rounded corners then we create an extension for
UIView as below
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
layer.masksToBounds = newValue > 0
}
}
}
9
Thank you !

Mais conteúdo relacionado

Mais procurados

Training Session 2
Training Session 2 Training Session 2
Training Session 2 Vivek Bhusal
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeAndiNurkholis1
 
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Claire Townend Gee
 
BuddyPress Groups API
BuddyPress Groups APIBuddyPress Groups API
BuddyPress Groups APIapeatling
 
Parallactic Collection Views
Parallactic Collection ViewsParallactic Collection Views
Parallactic Collection ViewsRené Cacheaux
 
Akka Presentation Schule@synyx
Akka Presentation Schule@synyxAkka Presentation Schule@synyx
Akka Presentation Schule@synyxFlorian Hopf
 
Get started azure- Azure Mobile Services
Get started azure- Azure Mobile ServicesGet started azure- Azure Mobile Services
Get started azure- Azure Mobile ServicesSenthamil Selvan
 
First step to Mobile x Angular @ the beginning of 2019
First step to Mobile x Angular @ the beginning of 2019First step to Mobile x Angular @ the beginning of 2019
First step to Mobile x Angular @ the beginning of 2019ssuser2fe195
 
Modular View Controller Hierarchies
Modular View Controller HierarchiesModular View Controller Hierarchies
Modular View Controller HierarchiesRené Cacheaux
 
Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Son Nguyen
 
Andorid Study Jams | DSC UNIDEB | DSC KU
Andorid Study Jams | DSC UNIDEB | DSC KUAndorid Study Jams | DSC UNIDEB | DSC KU
Andorid Study Jams | DSC UNIDEB | DSC KUMuhammad Raza
 
Asp.net mvc - Better User Experience with Kendo UI
Asp.net mvc - Better User Experience with Kendo UIAsp.net mvc - Better User Experience with Kendo UI
Asp.net mvc - Better User Experience with Kendo UILohith Goudagere Nagaraj
 
Gigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingGigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingAlex Rupérez
 
NSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity FrameworkNSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity FrameworkAlex Rupérez
 
Unpacking Developer Experience
Unpacking Developer ExperienceUnpacking Developer Experience
Unpacking Developer ExperienceAmit Jotwani
 

Mais procurados (20)

Training Session 2
Training Session 2 Training Session 2
Training Session 2
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack Compose
 
C# 6.0 and 7.0 new features
C# 6.0 and 7.0 new featuresC# 6.0 and 7.0 new features
C# 6.0 and 7.0 new features
 
Mobility testing
Mobility testingMobility testing
Mobility testing
 
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
Swift LA Meetup at eHarmony- Swift and Enterprise and eHarmony with Heena Ras...
 
BuddyPress Groups API
BuddyPress Groups APIBuddyPress Groups API
BuddyPress Groups API
 
Parallactic Collection Views
Parallactic Collection ViewsParallactic Collection Views
Parallactic Collection Views
 
Akka Presentation Schule@synyx
Akka Presentation Schule@synyxAkka Presentation Schule@synyx
Akka Presentation Schule@synyx
 
Get started azure- Azure Mobile Services
Get started azure- Azure Mobile ServicesGet started azure- Azure Mobile Services
Get started azure- Azure Mobile Services
 
First step to Mobile x Angular @ the beginning of 2019
First step to Mobile x Angular @ the beginning of 2019First step to Mobile x Angular @ the beginning of 2019
First step to Mobile x Angular @ the beginning of 2019
 
Modular View Controller Hierarchies
Modular View Controller HierarchiesModular View Controller Hierarchies
Modular View Controller Hierarchies
 
Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!Quality sdk for your apis in minutes!
Quality sdk for your apis in minutes!
 
Raptor 2
Raptor 2Raptor 2
Raptor 2
 
Andorid Study Jams | DSC UNIDEB | DSC KU
Andorid Study Jams | DSC UNIDEB | DSC KUAndorid Study Jams | DSC UNIDEB | DSC KU
Andorid Study Jams | DSC UNIDEB | DSC KU
 
Xamarin
XamarinXamarin
Xamarin
 
Asp.net mvc - Better User Experience with Kendo UI
Asp.net mvc - Better User Experience with Kendo UIAsp.net mvc - Better User Experience with Kendo UI
Asp.net mvc - Better User Experience with Kendo UI
 
Gigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingGigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die trying
 
C# everywhere
C# everywhereC# everywhere
C# everywhere
 
NSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity FrameworkNSCoder Keynote - Multipeer Connectivity Framework
NSCoder Keynote - Multipeer Connectivity Framework
 
Unpacking Developer Experience
Unpacking Developer ExperienceUnpacking Developer Experience
Unpacking Developer Experience
 

Destaque

Lista de cotejo de 3 años instrumento con rutas version 2015
Lista de cotejo de 3 años instrumento con rutas version 2015Lista de cotejo de 3 años instrumento con rutas version 2015
Lista de cotejo de 3 años instrumento con rutas version 2015puqui
 
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017Kaustuba Venugopal
 
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記Yurie Saitoh
 
Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017
 Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017 Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017
Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017Julia Helfer
 
Ciudad y plano
Ciudad y planoCiudad y plano
Ciudad y planoGeopress
 
Vodafone app UX analysis
Vodafone app UX analysisVodafone app UX analysis
Vodafone app UX analysisYogesh Awasthi
 
Ultimos avances (antonio)
Ultimos avances (antonio)Ultimos avances (antonio)
Ultimos avances (antonio)Joaquin Lopez
 
Europe in 2015
Europe in 2015Europe in 2015
Europe in 2015Maya
 
SUMA, RESTA, MULTIPLICACIÓ DECIMALS
SUMA, RESTA, MULTIPLICACIÓ DECIMALSSUMA, RESTA, MULTIPLICACIÓ DECIMALS
SUMA, RESTA, MULTIPLICACIÓ DECIMALSMarta Baró Sancho
 
Vamos a observar el paisaje.pptx
Vamos a observar el paisaje.pptxVamos a observar el paisaje.pptx
Vamos a observar el paisaje.pptxMei_87
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchMatteo Battaglio
 
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...Emma Mirrington
 
LEY GENERAL DE EDUCACIÓN 2013
LEY GENERAL DE EDUCACIÓN 2013LEY GENERAL DE EDUCACIÓN 2013
LEY GENERAL DE EDUCACIÓN 2013hugomedina36
 
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...Emma Mirrington
 

Destaque (18)

Ciencia, ¿técnica o servicio?
Ciencia, ¿técnica o servicio?Ciencia, ¿técnica o servicio?
Ciencia, ¿técnica o servicio?
 
Lista de cotejo de 3 años instrumento con rutas version 2015
Lista de cotejo de 3 años instrumento con rutas version 2015Lista de cotejo de 3 años instrumento con rutas version 2015
Lista de cotejo de 3 años instrumento con rutas version 2015
 
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017
KQA - Shankar PoLi, Poli Shankara and Kampni. Karnataka Quiz - 2017
 
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記
CodeforKohoku 成果発表会 よそものエンジニアが見たOKPと港北区の父さん母さん達の奮闘記
 
Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017
 Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017 Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017
Alyvix: Synthetic Monitoring @ Icinga Camp Berlin 2017
 
Ciudad y plano
Ciudad y planoCiudad y plano
Ciudad y plano
 
Vodafone app UX analysis
Vodafone app UX analysisVodafone app UX analysis
Vodafone app UX analysis
 
Ultimos avances (antonio)
Ultimos avances (antonio)Ultimos avances (antonio)
Ultimos avances (antonio)
 
Europe in 2015
Europe in 2015Europe in 2015
Europe in 2015
 
SUMA, RESTA, MULTIPLICACIÓ DECIMALS
SUMA, RESTA, MULTIPLICACIÓ DECIMALSSUMA, RESTA, MULTIPLICACIÓ DECIMALS
SUMA, RESTA, MULTIPLICACIÓ DECIMALS
 
Vamos a observar el paisaje.pptx
Vamos a observar el paisaje.pptxVamos a observar el paisaje.pptx
Vamos a observar el paisaje.pptx
 
Search API
Search APISearch API
Search API
 
Publicidad Inca kola - La Gordita
Publicidad Inca kola - La GorditaPublicidad Inca kola - La Gordita
Publicidad Inca kola - La Gordita
 
Centrifugacion
CentrifugacionCentrifugacion
Centrifugacion
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...
#FIRMday Manchester 9th March 2017: Kate Temple-Brown: 20 Challenges of the A...
 
LEY GENERAL DE EDUCACIÓN 2013
LEY GENERAL DE EDUCACIÓN 2013LEY GENERAL DE EDUCACIÓN 2013
LEY GENERAL DE EDUCACIÓN 2013
 
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...
#FIRMday Manchester 9th March 2017: WilsonHCG 'Employment Branding Evolution ...
 

Semelhante a IBDesignable & IBInspectible

Assignment1 A 0
Assignment1 A 0Assignment1 A 0
Assignment1 A 0Mahmoud
 
iOS App Development with Storyboard
iOS App Development with StoryboardiOS App Development with Storyboard
iOS App Development with StoryboardBabul Mirdha
 
Assignment 4 Paparazzi1
Assignment 4 Paparazzi1Assignment 4 Paparazzi1
Assignment 4 Paparazzi1Mahmoud
 
Deploy your app with one Slack command
Deploy your app with one Slack commandDeploy your app with one Slack command
Deploy your app with one Slack commandFabio Milano
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type scriptRavi Mone
 
What’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesWhat’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesRigel Networks LLC
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOCCarl Lu
 
You Know Angular 2, You Know Native Mobile App Development
You Know Angular 2, You Know Native Mobile App DevelopmentYou Know Angular 2, You Know Native Mobile App Development
You Know Angular 2, You Know Native Mobile App DevelopmentLohith Goudagere Nagaraj
 
Integrating Indigo.Design App Builder with GitHub
Integrating Indigo.Design App Builder with GitHubIntegrating Indigo.Design App Builder with GitHub
Integrating Indigo.Design App Builder with GitHubJohnMcGuigan10
 
Top 7 react developer tools to use in 2021
Top 7 react developer tools to use in 2021Top 7 react developer tools to use in 2021
Top 7 react developer tools to use in 2021WrapPixel
 
Jetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIJetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIGilang Ramadhan
 
How to Choose the Best Platform for iOS App Development?
How to Choose the Best Platform for iOS App Development?How to Choose the Best Platform for iOS App Development?
How to Choose the Best Platform for iOS App Development?SemaphoreSoftware1
 
Kotlin With JetPack Compose Presentation
Kotlin With JetPack Compose PresentationKotlin With JetPack Compose Presentation
Kotlin With JetPack Compose PresentationKnoldus Inc.
 

Semelhante a IBDesignable & IBInspectible (20)

Assignment1 A 0
Assignment1 A 0Assignment1 A 0
Assignment1 A 0
 
iOS App Development with Storyboard
iOS App Development with StoryboardiOS App Development with Storyboard
iOS App Development with Storyboard
 
iOS UI best practices
iOS UI best practicesiOS UI best practices
iOS UI best practices
 
Assignment 4 Paparazzi1
Assignment 4 Paparazzi1Assignment 4 Paparazzi1
Assignment 4 Paparazzi1
 
Deploy your app with one Slack command
Deploy your app with one Slack commandDeploy your app with one Slack command
Deploy your app with one Slack command
 
iOS storyboard
iOS storyboardiOS storyboard
iOS storyboard
 
200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
What’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development OpportunitiesWhat’s new in Xcode 8? – Future of Native App Development Opportunities
What’s new in Xcode 8? – Future of Native App Development Opportunities
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
You Know Angular 2, You Know Native Mobile App Development
You Know Angular 2, You Know Native Mobile App DevelopmentYou Know Angular 2, You Know Native Mobile App Development
You Know Angular 2, You Know Native Mobile App Development
 
Integrating Indigo.Design App Builder with GitHub
Integrating Indigo.Design App Builder with GitHubIntegrating Indigo.Design App Builder with GitHub
Integrating Indigo.Design App Builder with GitHub
 
Top 7 react developer tools to use in 2021
Top 7 react developer tools to use in 2021Top 7 react developer tools to use in 2021
Top 7 react developer tools to use in 2021
 
Jetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIJetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UI
 
Angular IO
Angular IOAngular IO
Angular IO
 
How to Choose the Best Platform for iOS App Development?
How to Choose the Best Platform for iOS App Development?How to Choose the Best Platform for iOS App Development?
How to Choose the Best Platform for iOS App Development?
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
201010 SPLASH Tutorial
201010 SPLASH Tutorial201010 SPLASH Tutorial
201010 SPLASH Tutorial
 
IOS Storyboards
IOS StoryboardsIOS Storyboards
IOS Storyboards
 
Kotlin With JetPack Compose Presentation
Kotlin With JetPack Compose PresentationKotlin With JetPack Compose Presentation
Kotlin With JetPack Compose Presentation
 

Mais de Gagan Vishal Mishra

Mais de Gagan Vishal Mishra (8)

iOS Versions history
iOS Versions historyiOS Versions history
iOS Versions history
 
Core data optimization
Core data optimizationCore data optimization
Core data optimization
 
Jenkins CI/CD setup for iOS in Mac OSX
Jenkins CI/CD setup for iOS in Mac OSXJenkins CI/CD setup for iOS in Mac OSX
Jenkins CI/CD setup for iOS in Mac OSX
 
Linking between JIRA & GIT, Smart Commit Command
Linking between JIRA & GIT, Smart Commit Command Linking between JIRA & GIT, Smart Commit Command
Linking between JIRA & GIT, Smart Commit Command
 
Backbase CXP Manager Setup
Backbase CXP Manager SetupBackbase CXP Manager Setup
Backbase CXP Manager Setup
 
Dynamic databinding
Dynamic databindingDynamic databinding
Dynamic databinding
 
Visual Formatting Language in iOS
Visual Formatting Language in iOSVisual Formatting Language in iOS
Visual Formatting Language in iOS
 
Core Data Performance Guide Line
Core Data Performance Guide LineCore Data Performance Guide Line
Core Data Performance Guide Line
 

Último

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Último (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

IBDesignable & IBInspectible

  • 1. Presenter Intro. IBDesignable and IBInspectable By: Gagan Vishal Mishra
  • 2. Introduction IBDesignable & IBInspectable 2 • In Xcode 6, Apple has introduced the live rendering feature of Interface Builder that allows developer to design and inspect a custom view on the Interface Builder canvas. • This feature provides ability to preview and modify custom components at design time via @IBDesignable and @IBInspectable. • IBDesignable and IBInspectable are related to each other, first one applies to the class definition, the second one applies to the properties. • Every time you open the Interface Builder, Xcode quickly compiles the nib. This uses the initializers and the drawing methods to update the xib/storyboard in real time.
  • 3. IBDesignable IBDesignable & IBInspectable 3 • Prefixing class with the @IBDesignable keyword to inform Interface Builder that the class instances will try to design themselves when added to the storyboard. • Adding a class with the @IBDesignable keyword allows compiler that any problems can be debugged without compiling and running the whole project. To kick off a debugging session right in place 1. Simply set a breakpoint in your code. 2. Select the view in Interface Builder. 3. Choose Editor ➔ Debug Selected Views.
  • 4. IBDesignable IBDesignable & IBInspectable 4 IBDesignable uses the initializers and the drawing methods to update the xib/storyboard in real time. IBDesignable attribute can be added to the class declaration, class extension, or category for a custom view. It can be added as below Objective-C IB_DESIGNABLE @interface YourView: UIView Swift @IBDesignable class YourView: UIView
  • 5. IBDesignable IBDesignable & IBInspectable 5 Some time the custom view won’t have the full data of the app when rendered in Interface Builder, we may need to generate the data later for displaying in view e.g. user image from server etc. There are two ways to implement it 1.prepareForInterfaceBuilder() : compiles with the rest of your code but is only executed when your view is being prepared for display in Interface Builder. 2.TARGET_INTERFACE_BUILDER: Add run time condition check #if !TARGET_INTERFACE_BUILDER // this code will run in the app itself #else // this code will execute only in IB #endif
  • 6. IBInspectable IBDesignable & IBInspectable 6 • Prefixing any properties of the class with @IBInspectable, we ensure that Interface Builder can read and write the value of these properties directly in the inspector view. • These properties will allow you to change the outlet class in real time. • Properties can be created as below Objective-C @property (nonatomic) IBInspectable Type * yourVariable; Swift @IBInspectable var yourVariable: Type() =Type()
  • 7. IBInspectable IBDesignable & IBInspectable 7 • Only a limited data types can be set to IBInspectable 1. Int 2. CGFloat 3. Double 4. String 5. Bool 6. CGPoint 7. CGSize 8. CGRect 9. UIColor 10. UIImage
  • 8. IBInspectable IBDesignable & IBInspectable 8 • Making Existing Types Inspectable: Built-in Cocoa types can also be extended to have inspectable properties beyond the ones already in Interface Builder’s attribute inspector. If you like rounded corners then we create an extension for UIView as below extension UIView { @IBInspectable var cornerRadius: CGFloat { get { return layer.cornerRadius } set { layer.cornerRadius = newValue layer.masksToBounds = newValue > 0 } } }

Notas do Editor

  1. http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6 2. http://www.brightec.co.uk/ideas/ibdesignable-and-ibinspectable-coregraphics
  2. http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6 http://www.brightec.co.uk/ideas/ibdesignable-and-ibinspectable-coregraphics http://nshipster.com/ibinspectable-ibdesignable/ https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/Chapters/CreatingaLiveViewofaCustomObject.html http://www.brightec.co.uk/ideas/ibdesignable-and-ibinspectable-coregraphics
  3. http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6 http://www.brightec.co.uk/ideas/ibdesignable-and-ibinspectable-coregraphics http://nshipster.com/ibinspectable-ibdesignable/ https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/Chapters/CreatingaLiveViewofaCustomObject.html http://www.brightec.co.uk/ideas/ibdesignable-and-ibinspectable-coregraphics