2. • What’s new in Cocoa Touch
• The keys to a better text input experience
• Introducing password autofill for apps
• Building apps with dynamic type
• Updating your app for iOS 11
• Advanced animations with UIKit
5. Drag and Drop
Enabling drags
let drag = UIDragInteraction(delegate: self)
iconView.addInteraction(drag)
UIDragInteractionDelegate
• Provide data for dragged item
• Customize lift animation
• Customize preview
6. Drag and Drop
Enabling drops
let drop = UIDropInteraction(delegate: self)
iconContainerView.addInteraction(drop)
UIDropInteractionDelegate
• Update UI as drag moves
• Receive data on drop
• Customize drop animation
7. Drag and Drop
Easy to adopt
Introducing Drag and Drop Hall 3 Tuesday 11:20AM
Mastering Drag and Drop Executive Ballroom Wednesday 11:00AM
Drag and Drop with Collection and Table View Hall 2 Thursday 9:00AM
Data Delivery with Drag and Drop Hall 2 Thursday 10:00AM
Built-in support
• TableView, CollectionView, TextView, TextField, WebView
Integration with UIPasteConfiguration
9. Highly customizable
Access to local documents and cloud storage
Be sure to coordinate file access
• NSFileCoordinator or UIDocument
File Management
UIDocumentBrowserViewController
Building Great Document-Based Apps in iOS 11 Hall 2 Thursday 1:50PM
class UIDocumentBrowserViewController {
init(forOpeningFilesWithContentTypes: [String]?)
var delegate: UIDocumentBrowserViewControllerDelegate?
}
10.
11. class UINavigationBar {
var prefersLargeTitle: Bool
}
Enabling Large Titles
class UINavigationItem {
var largeTitleDisplayMode: LargeTitleDisplayMode
}
13. Safe Area Insets
class UIView {
// auto layout
var safeAreaLayoutGuide: UILayoutGuide { get }
// manual layout
var safeAreaInsets: UIEdgeInsets { get }
func safeAreaInsetsDidChange()
}
15. Asset Catalogs
Colors and icons
class UIColor {
init?(named name: String)
}
Wide gamut color support
Wide gamut colors for icons
App thinning for icons
19. Text Input Context Identifier
class ConversationViewController: UITableViewController, UITextViewDelegate {
// ... other code ...
override var textInputContextIdentifier: String? {
// Returning some unique identifier here allows the keyboard to remember
// which language the user was typing in when they were last communicating
// with this person.
// It can be anything, as long as it's unique to each
// recipient (here we're just returning the name)
return self.conversation?.otherParticipant
}
// ... other code ...
}
Multilingual
20. Content Types for Password AutoFill
Introducing Password AutoFill for Apps WWDC 2017
NEW
Log In
UITextContentTypeUsername
UITextContentTypePassword
21. Smart Quote and Smart Dash
Hyphen: 1-dash - ➜ -
En dash: 2-dash - - ➜ –
Em dash: 3-dash - - - ➜ —
SF Hello "a" “a”
Helvetica Neue "a" “a”
Lucida Grande "a" “a”
Avenir "a" “a”
Myriad Set "a" “a”
NEW
22. New APIs in iOS 11
Selected text
documentIdentifier handle
Ability to query for full access
NEW
23. Full Access and Privacy
Value in not asking for full access
Communicating with your main app
Networking
Current location
Address book
Keyboard needs to work without it
25. Make the QuickType Bar Appear
Use UITextContentType
Deploy content types to guarantee AutoFill is available
Can set in code or through Interface Builder
UITextContentType.username enables AutoFill for two-screen login
You can combine UITextContentType.username and UIKeyboardType.emailAddress
UITextContentType.password enables AutoFill for “revealed” passwords
26.
27. Associated Domains File
Where to serve the file
https://example.com/.well-known/apple-app-site-association
https://example.com/apple-app-site-association
42. Make Layout Decisions Based on Text Size
if traitCollection.preferredContentSizeCategory.isAccessibilityCategory {
// Vertically stack
} else {
// Lay out side by side
}
NEW
43. Make Layout Decisions Based on Text Size
if traitCollection.preferredContentSizeCategory > .extraExtraLarge {
// Vertically stack
} else {
// Lay out side by side
}
NEW
44. Default Table View Behaviors in iOS 11
Standard table view cells adapt layout for Dynamic Type
Cell heights are based on their content
NEW
53. NEW
Here’s to the crazy ones. The misfits. The
rebels. The troublemakers. The round pegs
in the square holes. The ones who see
things differently. They’re not fond of rules.
And they have no respect for the status quo.
You can quote them, disagree with them,
glorify or vilify them. About the only thing
you can’t do is ignore them. Because they
change things. They push the human race
forward. And while some may see them as
the crazy ones, we see genius. Because the
people who are crazy enough to think they
can change the world, are the ones who do.
Title
layoutMargins
directionalLayoutMargins
54. NEW
Here’s to the crazy ones. The misfits. The
rebels. The troublemakers. The round pegs
in the square holes. The ones who see
things differently. They’re not fond of rules.
And they have no respect for the status quo.
You can quote them, disagree with them,
glorify or vilify them. About the only thing
you can’t do is ignore them. Because they
change things. They push the human race
forward. And while some may see them as
the crazy ones, we see genius. Because the
people who are crazy enough to think they
can change the world, are the ones who do.
Title
.trailing
.left
.leading
.right
55. NEW
Here’s to the crazy ones. The
misfits. The rebels. The
troublemakers. The round pegs in
the square holes. The ones who see
things differently. They’re not fond
of rules. And they have no respect
for the status quo. You can quote
them, disagree with them, glorify or
vilify them. About the only thing you
can’t do is ignore them. Because
they change things. They push the
human race forward. And while
some may see them as the crazy
ones, we see genius. Because the
people who are crazy enough to
think they can change the world,
are the ones who do.
Title
.trailing = 30
56. NEW
Here’s to the crazy ones. The
misfits. The rebels. The
troublemakers. The round pegs in
the square holes. The ones who see
things differently. They’re not fond
of rules. And they have no respect
for the status quo. You can quote
them, disagree with them, glorify or
vilify them. About the only thing you
can’t do is ignore them. Because
they change things. They push the
human race forward. And while
some may see them as the crazy
ones, we see genius. Because the
people who are crazy enough to
think they can change the world,
are the ones who do.
ֶֶרתתּכֹו
.left = 30
.trailing = 30
57. NEW
Here’s to the crazy ones. The
misfits. The rebels. The
troublemakers. The round
pegs in the square holes. The
ones who see things
differently. They’re not fond of
rules. And they have no
respect for the status quo.
You can quote them, disagree
with them, glorify or vilify
them. About the only thing
you can’t do is ignore them.
Because they change things.
They push the human race
forward. And while some may
see them as the crazy ones,
we see genius. Because the
Title
systemMinimumLayoutMargins
directionalLayoutMargins
class MyViewController: UIViewController {
override func viewDidLoad() {
viewRespectsSystemMinimumLayoutMargins = true // default
}
}
59. Safe Area
Describes area of view not occluded
by ancestors
Available as insets or layout guide
Incorporates overscan compensation insets
NEW
UIView.safeAreaInsets
60. Safe Area
Describes area of view not occluded
by ancestors
Available as insets or layout guide
Incorporates overscan compensation insets
NEW
UIView.safeAreaLayoutGuide
61. Safe Area
Describes area of view not occluded
by ancestors
Available as insets or layout guide
Incorporates overscan compensation insets
NEW
UIScreen.overscanCompensationInsets
62. Extending the Safe Area Insets
UIViewController.additionalSafeAreaInsets
UIView.safeAreaInsetsDidChange()
UIViewController.viewSafeAreaInsetsDidChange()
NEW
63. Title
Here’s to the crazy ones.
The misfits. The rebels. The
troublemakers. The round
pegs in the square holes.
The ones who see things
differently. They’re not fond
of rules. And they have no
respect for the status quo.
You can quote them,
disagree with them, glorify
or vilify them. About the only
thing you can’t do is ignore
them. Because they change
things. They push the
human race forward. And
while some may see them as
the crazy ones, we see
genius. Because the people
who are crazy enough to
think they can change the
world, are the ones who do.
NEW
101 words • Modified today
adjustedContentInset.top
contentInset.top
64. Safe Area Insets
class UIScrollView {
var contentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentBehavior
var adjustedContentInset: UIEdgeInsets { get }
}
65. 101 words • Modified today
NEWTitle
Here’s to the crazy ones.
The misfits. The rebels. The
troublemakers. The round
pegs in the square holes.
The ones who see things
differently. They’re not fond
of rules. And they have no
respect for the status quo.
You can quote them,
disagree with them, glorify
or vilify them. About the only
thing you can’t do is ignore
them. Because they change
things. They push the
human race forward. And
while some may see them as
the crazy ones, we see
genius. Because the people
who are crazy enough to
think they can change the
world, are the ones who do.
contentLayoutGuide
Page 1
frameLayoutGuide
66. Self-Sizing by Default
Link on iOS 11, all estimated heights default to UITableViewAutomaticDimension
Headers, footers, and cells use self-sizing by default
iOS only—behavior is not changed on tvOS
Ensure all views have sufficient internal constraints
Return fixed sizes from delegate methods
NEW
67. Opting Out of New Behavior
Set table view estimated height properties to zero
Also disables self-sizing
override func viewDidLoad() {
tableView.estimatedRowHeight = 0
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
}
NEW
70. Swipe Actions
New look-and-feel automatically for all
table views
Supports full swipe-to-delete for iOS
11-linked apps
New features with API adoption
• Images
• Leading and trailing actions
• Completion handler and cancellation
NEW
84. Starting as Paused
let animator = UIViewPropertyAnimator(duration: 1, curve: .easeIn)
animator.startAnimation()
// ...
animator.addAnimations {
// will run immediately
circle.frame = circle.frame.offsetBy(dx: 100, dy: 0)
}
No escaping for animation blocks
NEW
85. .cornerRadius
Now animatable in UIKit
CALayer
var .cornerRadius: CGFloat
circle.clipsToBounds = true
UIViewPropertyAnimator(duration: 1, curve: .linear) {
circle.layer.cornerRadius = 12
}.startAnimation()
NEW
86. .maskedCorners
New in iOS 11
CALayer
var .maskedCorners: CACornerMask
circle.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
NEW