SlideShare a Scribd company logo
More iOS UI Considerations
Lecture 06:Attributed Strings and Auto Layout
Jonathan R. Engelsma, Ph.D.
TOPICS
• Attributed Strings
• Autorotation
• Auto Layout
ATTRIBUTED STRINGS
• Attributed String: text with multiple style runs with different
font, size, color and other text features in different parts of the
text.
• NSAttributedString / NSMutableAttributedStrings were
promoted in iOS6 and are now much more easier to work
with!
• e.g. integrated with UI controls that deal with text: UILabel,
UITextView.
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html#//apple_ref/doc/uid/10000036-BBCCGDBG
ATTRIBUTED STRING
FEATURES
• Attributes can be associated with single characters, a range of
characters or the entire string.
• Preservation of attribute-to-character mappings after changes.
• Support for RTF, including file attachments and graphics.
• Linguistic unit (word) and line calculations
ATTRIBUTED STRINGS
if let font = UIFont(name: "Noteworthy-Bold", size: 18) {
let attributes = [NSFontAttributeName : font,
NSUnderlineStyleAttributeName : 1,
NSForegroundColorAttributeName : UIColor.redColor()]
let lab1 : NSAttributedString =
NSAttributedString(string: "Fancy Red Apples",
attributes: attributes)
label1.attributedText = lab1
}
ATTRIBUTED STRINGS
if var font = UIFont(name:"Zapfino", size: 18) {
let attributes = [NSFontAttributeName : font]
let lab2 = NSAttributedString(
string: "Snazzy Fonts r Us!",
attributes: attributes)
label2.attributedText = lab2
}
ATTRIBUTED STRINGS
if var font = UIFont(name:"Helvetica", size: 24) {
let attributes = [NSFontAttributeName : font,
NSForegroundColorAttributeName : UIColor.greenColor()]
let lab3 = NSAttributedString(
string: "Green is Golden",
attributes: attributes)
label3.attributedText = lab3
}
ATTRIBUTED STRINGS
var lakerString : String = "Laker Blue"
var font =
UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
let attributes = [NSFontAttributeName : font]
let lab4 = NSMutableAttributedString(
string: lakerString,
attributes: attributes)
label4.attributedText = lab4
// change attrs on a substring.
let nsText = lakerString as NSString
let r = nsText.rangeOfString("Blue")
lab4.addAttribute(
NSForegroundColorAttributeName, value:
UIColor.blueColor(),
range: r)
label4.attributedText = lab4
AVAILABLE ATTRIBUTES
Font Paragraph Style Foreground Color
Background Color Ligature Kern
Strikethrough Style Underline Style Stroke Color
Stroke Width Shadow Text Effect
Attachment Link Baseline Offset
Underline Color Strikethrough Color Obliqueness
Expansion Writing Direction Vertical Glyph Form
https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/Reference/Reference.html
ATTRIBUTED STRING DEMO
OTHER IOS UI CHALLENGES
There are several different screen
sizes that have to be supported!
APPROACHES USED
• Handling different iPhone / iPodTouch screen sizes:
• Normally done via Auto Layout and legacy springs-and-
struts based autosizing approach.
• Supporting iPad:
• Usually an entirely different layout in a separate storyboard.
• Still can do significant amount of code reuse though!
AUTO LAYOUT
• Introduced in iOS 6.
• Replaces the legacy springs-
and-struts based autosizing.
• builds relationships between
views, specifying how views
and their superviews related
to each other.
AUTO LAYOUT
• Auto Layout is based on the Cassowary constraint-solving
toolkit developed at the University of Washington.
• Solves systems of linear equalities / inequalities based on
constraints.
• Constraints are rules that describe how one view’s layout is
limited with respect to another.
• Constraints can either be requirements or preferences.
AUTO LAYOUT
• Has the reputation for being hard to use. (An entire book has
been written on the subject!).
• In reality, it is not so bad, and gives you significant flexibility in
designing layouts over the legacy mechanisms.
• Can adopt incrementally. (e.g. not every view in our app has
to utilize Auto Layout - can introduce controller at a time!)
TURNING ON AUTO LAYOUT
• Select any view controller in
Interface Builder.
• Open the file inspector (⌘
- 1).
• Under the Interface Builder
Document section, make
sure “Use AutoLayout” is
checked.
USING AUTO LAYOUT
• Constraints can be expressed programmatically in Objective-C
/ Swift code.
• Constraints can be established “visually” using Interface Builder.
• Detects/suggests missing constraints.
• Warns and flags errors.
CONSTRAINT EXAMPLES
• Match one view’s size to another view’s size so they are always
the same width.
• Center a view (or group of views) in a superview, not matter
how the superview resizes.
• Align the bottoms of several views.
• Tie the bottom of one view to the top of another, so if one
moves the other will.
• Prevent an image view from shrinking beyond a certain size.
SOME RULES OFTHUMB
• In IB, always use the “snapping”
guides when doing layouts.
• Use “default” or standard
spacings - beware of rules with
“magic” numbers in them.
• Always fix layout warnings/
errors in IB before attempting
to run.
• Keep an eye on the debug log!
AUTO LAYOUT DEMO
AUTOROTATION
• If the user changes the device orientation (e.g. portrait to
landscape or vice versa) the app might want to adjust the
screen layout:
User changes
device orientation.
AUTOROTATION
• When the device is rotated, the top level view will have its
bounds reoriented if:
• view controller returnsYES from method shouldAutoRotate
• app allows rotation to that orientation (see general tab on
app target in xCode)
• view controller returns the new orientation in the method
supportedInterfaceOrientations.
USE OF ROTATION
• Compensatory - adjust the display to accommodate how the
user is holding the device
• Forced Rotation - force the orientation because the
interface has been designed specifically for a given orientation.
AUTOROTATION
• Try to support different device orientations, when they make
sense!
• Supporting landscape is particularly useful when the soft
keypad is displayed and user is entering text!
• Autolayout constraints may help you support the 90 degree
different orientations, but not always!
AUTOROTATION DEMO
READING ASSIGNMENT
• Chapter 1: Programming
iOS 8 (by Neuburg) (See
Auto Layout material in this
chapter)

More Related Content

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)

Dive Into Mobile - Guidelines for Testing, Native and Web Apps
Dive Into Mobile - Guidelines for Testing, Native and Web AppsDive Into Mobile - Guidelines for Testing, Native and Web Apps
Dive Into Mobile - Guidelines for Testing, Native and Web Apps
Susan Hewitt
 
iOS storyboard
iOS storyboardiOS storyboard
iOS storyboard
MinHyeok Kim
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
Vu Tran Lam
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1
Manoj Ellappan
 
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Derek Lee Boire
 
Ios
IosIos
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
Mindfire Solutions
 
How to: A starters guide for app development on Apple Watch
How to: A starters guide for app development on Apple WatchHow to: A starters guide for app development on Apple Watch
How to: A starters guide for app development on Apple Watch
SoftTeco
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app
Ivano Malavolta
 
iOS App performance - Things to take care
iOS App performance - Things to take careiOS App performance - Things to take care
iOS App performance - Things to take care
Gurpreet Singh Sachdeva
 
Adaptive UI for Android and iOS using Material and Cupertino.pptx
Adaptive UI for Android and iOS using Material and Cupertino.pptxAdaptive UI for Android and iOS using Material and Cupertino.pptx
Adaptive UI for Android and iOS using Material and Cupertino.pptx
Flutter Agency
 
Ux ui presentation2
Ux ui presentation2Ux ui presentation2
Ux ui presentation2
GeneXus
 
iOS UI best practices
iOS UI best practicesiOS UI best practices
iOS UI best practices
DianaKhersonskaia
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
Jussi Pohjolainen
 
Apple Watch Human Interface Guidelines
Apple Watch Human Interface GuidelinesApple Watch Human Interface Guidelines
Apple Watch Human Interface Guidelines
ShengWen Chiou
 
Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012
Jan Kroon
 
Workshop 04 android-development
Workshop 04 android-developmentWorkshop 04 android-development
Workshop 04 android-development
Aravindharamanan S
 
Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhone
Vu Tran Lam
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
Jean-Luc David
 
iOS 7 Transition guide
iOS 7 Transition guideiOS 7 Transition guide
iOS 7 Transition guide
Jigar Maheshwari
 

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06) (20)

Dive Into Mobile - Guidelines for Testing, Native and Web Apps
Dive Into Mobile - Guidelines for Testing, Native and Web AppsDive Into Mobile - Guidelines for Testing, Native and Web Apps
Dive Into Mobile - Guidelines for Testing, Native and Web Apps
 
iOS storyboard
iOS storyboardiOS storyboard
iOS storyboard
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1
 
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
Adjusting to Auto Layout (Tutorial / Tips for iOS Auto Layout)
 
Ios
IosIos
Ios
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
How to: A starters guide for app development on Apple Watch
How to: A starters guide for app development on Apple WatchHow to: A starters guide for app development on Apple Watch
How to: A starters guide for app development on Apple Watch
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app
 
iOS App performance - Things to take care
iOS App performance - Things to take careiOS App performance - Things to take care
iOS App performance - Things to take care
 
Adaptive UI for Android and iOS using Material and Cupertino.pptx
Adaptive UI for Android and iOS using Material and Cupertino.pptxAdaptive UI for Android and iOS using Material and Cupertino.pptx
Adaptive UI for Android and iOS using Material and Cupertino.pptx
 
Ux ui presentation2
Ux ui presentation2Ux ui presentation2
Ux ui presentation2
 
iOS UI best practices
iOS UI best practicesiOS UI best practices
iOS UI best practices
 
Android UI Development
Android UI DevelopmentAndroid UI Development
Android UI Development
 
Apple Watch Human Interface Guidelines
Apple Watch Human Interface GuidelinesApple Watch Human Interface Guidelines
Apple Watch Human Interface Guidelines
 
Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012Jan Kroon's talk @mdevcon 2012
Jan Kroon's talk @mdevcon 2012
 
Workshop 04 android-development
Workshop 04 android-developmentWorkshop 04 android-development
Workshop 04 android-development
 
Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhone
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
 
iOS 7 Transition guide
iOS 7 Transition guideiOS 7 Transition guide
iOS 7 Transition guide
 

More from Jonathan Engelsma

Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better Beekeeper
Jonathan Engelsma
 
BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program Overview
Jonathan Engelsma
 
Selling Honey Online
Selling Honey OnlineSelling Honey Online
Selling Honey Online
Jonathan Engelsma
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc.
Jonathan Engelsma
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
Jonathan Engelsma
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper?
Jonathan Engelsma
 
What Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsWhat Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile Apps
Jonathan Engelsma
 
Mobile Gamification
Mobile GamificationMobile Gamification
Mobile Gamification
Jonathan Engelsma
 
2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference
Jonathan Engelsma
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
Jonathan Engelsma
 

More from Jonathan Engelsma (15)

Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better Beekeeper
 
BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program Overview
 
Selling Honey Online
Selling Honey OnlineSelling Honey Online
Selling Honey Online
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc.
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper?
 
What Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsWhat Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile Apps
 
Mobile Gamification
Mobile GamificationMobile Gamification
Mobile Gamification
 
2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
 

Recently uploaded

Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 

Recently uploaded (20)

Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)

  • 1. More iOS UI Considerations Lecture 06:Attributed Strings and Auto Layout Jonathan R. Engelsma, Ph.D.
  • 2. TOPICS • Attributed Strings • Autorotation • Auto Layout
  • 3. ATTRIBUTED STRINGS • Attributed String: text with multiple style runs with different font, size, color and other text features in different parts of the text. • NSAttributedString / NSMutableAttributedStrings were promoted in iOS6 and are now much more easier to work with! • e.g. integrated with UI controls that deal with text: UILabel, UITextView. https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html#//apple_ref/doc/uid/10000036-BBCCGDBG
  • 4. ATTRIBUTED STRING FEATURES • Attributes can be associated with single characters, a range of characters or the entire string. • Preservation of attribute-to-character mappings after changes. • Support for RTF, including file attachments and graphics. • Linguistic unit (word) and line calculations
  • 5. ATTRIBUTED STRINGS if let font = UIFont(name: "Noteworthy-Bold", size: 18) { let attributes = [NSFontAttributeName : font, NSUnderlineStyleAttributeName : 1, NSForegroundColorAttributeName : UIColor.redColor()] let lab1 : NSAttributedString = NSAttributedString(string: "Fancy Red Apples", attributes: attributes) label1.attributedText = lab1 }
  • 6. ATTRIBUTED STRINGS if var font = UIFont(name:"Zapfino", size: 18) { let attributes = [NSFontAttributeName : font] let lab2 = NSAttributedString( string: "Snazzy Fonts r Us!", attributes: attributes) label2.attributedText = lab2 }
  • 7. ATTRIBUTED STRINGS if var font = UIFont(name:"Helvetica", size: 24) { let attributes = [NSFontAttributeName : font, NSForegroundColorAttributeName : UIColor.greenColor()] let lab3 = NSAttributedString( string: "Green is Golden", attributes: attributes) label3.attributedText = lab3 }
  • 8. ATTRIBUTED STRINGS var lakerString : String = "Laker Blue" var font = UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline) let attributes = [NSFontAttributeName : font] let lab4 = NSMutableAttributedString( string: lakerString, attributes: attributes) label4.attributedText = lab4 // change attrs on a substring. let nsText = lakerString as NSString let r = nsText.rangeOfString("Blue") lab4.addAttribute( NSForegroundColorAttributeName, value: UIColor.blueColor(), range: r) label4.attributedText = lab4
  • 9. AVAILABLE ATTRIBUTES Font Paragraph Style Foreground Color Background Color Ligature Kern Strikethrough Style Underline Style Stroke Color Stroke Width Shadow Text Effect Attachment Link Baseline Offset Underline Color Strikethrough Color Obliqueness Expansion Writing Direction Vertical Glyph Form https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/Reference/Reference.html
  • 11. OTHER IOS UI CHALLENGES There are several different screen sizes that have to be supported!
  • 12. APPROACHES USED • Handling different iPhone / iPodTouch screen sizes: • Normally done via Auto Layout and legacy springs-and- struts based autosizing approach. • Supporting iPad: • Usually an entirely different layout in a separate storyboard. • Still can do significant amount of code reuse though!
  • 13. AUTO LAYOUT • Introduced in iOS 6. • Replaces the legacy springs- and-struts based autosizing. • builds relationships between views, specifying how views and their superviews related to each other.
  • 14. AUTO LAYOUT • Auto Layout is based on the Cassowary constraint-solving toolkit developed at the University of Washington. • Solves systems of linear equalities / inequalities based on constraints. • Constraints are rules that describe how one view’s layout is limited with respect to another. • Constraints can either be requirements or preferences.
  • 15. AUTO LAYOUT • Has the reputation for being hard to use. (An entire book has been written on the subject!). • In reality, it is not so bad, and gives you significant flexibility in designing layouts over the legacy mechanisms. • Can adopt incrementally. (e.g. not every view in our app has to utilize Auto Layout - can introduce controller at a time!)
  • 16. TURNING ON AUTO LAYOUT • Select any view controller in Interface Builder. • Open the file inspector (⌘ - 1). • Under the Interface Builder Document section, make sure “Use AutoLayout” is checked.
  • 17. USING AUTO LAYOUT • Constraints can be expressed programmatically in Objective-C / Swift code. • Constraints can be established “visually” using Interface Builder. • Detects/suggests missing constraints. • Warns and flags errors.
  • 18. CONSTRAINT EXAMPLES • Match one view’s size to another view’s size so they are always the same width. • Center a view (or group of views) in a superview, not matter how the superview resizes. • Align the bottoms of several views. • Tie the bottom of one view to the top of another, so if one moves the other will. • Prevent an image view from shrinking beyond a certain size.
  • 19. SOME RULES OFTHUMB • In IB, always use the “snapping” guides when doing layouts. • Use “default” or standard spacings - beware of rules with “magic” numbers in them. • Always fix layout warnings/ errors in IB before attempting to run. • Keep an eye on the debug log!
  • 21. AUTOROTATION • If the user changes the device orientation (e.g. portrait to landscape or vice versa) the app might want to adjust the screen layout: User changes device orientation.
  • 22. AUTOROTATION • When the device is rotated, the top level view will have its bounds reoriented if: • view controller returnsYES from method shouldAutoRotate • app allows rotation to that orientation (see general tab on app target in xCode) • view controller returns the new orientation in the method supportedInterfaceOrientations.
  • 23. USE OF ROTATION • Compensatory - adjust the display to accommodate how the user is holding the device • Forced Rotation - force the orientation because the interface has been designed specifically for a given orientation.
  • 24. AUTOROTATION • Try to support different device orientations, when they make sense! • Supporting landscape is particularly useful when the soft keypad is displayed and user is entering text! • Autolayout constraints may help you support the 90 degree different orientations, but not always!
  • 26. READING ASSIGNMENT • Chapter 1: Programming iOS 8 (by Neuburg) (See Auto Layout material in this chapter)