New Features in iOS 15 and Swift 5.5.pdf

Katy Slemon
Katy SlemonSr. Tech Consultant at Bacancy Technology à Bacancy Technology

Find an article talking about new features in iOS and switft 5.5.

New Features
in iOS 15 and
Swift 5.5


https://www.bacancytechnology.com/
Introduction
New Features in iOS 15 and Swift 5.5.pdf
At Worldwide Developers Conference
21, Apple has overcome many
limitations by announcing some
important features for developers.
Apple has made sure while introducing
the new features in iOS 15 and Swift 5.5
that every developer can build the best
interactive applications with minimal
time and effort. In this blog post, we
will learn a few new features that have
been introduced and see how we can
implement them in our code.
New Features
in iOS 15 and
Swift 5.5
1. UISheetPresentation Controller
Apple provided some new API
improvements in WWDC 21 to present the
bottom sheets. In iOS 14, they introduced
this, but it didn’t have any customization,
but from iOS 15, we can implement apple
maps like a bottom sheet with a smaller
height. It has customization like height
adjustment, adding a grabber to the top of
the sheet.


UIViewController has a new property
called sheetPresentationController; you
can present the bottom sheet. We can
access the sheetPresentationController
property to get the instance of
UISheetPresentationController for
customizing its appearance.
@IBAction func openSheetAction(_
sender : UIButton) {
if let bSheet =
bottomSheet.sheetPresentationController
{
bSheet.detents = [.medium(),
.large()]
bSheet.prefersGrabberVisible = true
bSheet.largestUndimmedDetentIdentifie
r = .medium
bSheet.prefersScrollingExpandsWhenScr
olledToEdge = false
bSheet.preferredCornerRadius = 30.0
}
present(bottomSheet, animated: true,
completion: nil)
}
Here, we can use detents to adjust the
height of the bottom sheet. It has 2
values .large() & .medium(). .large() will
show height for full screen & .medium()
will occupy height of half of screen
height. Here, We have passed an array
for detents, so first, it will show in half
of the screen height & then we can drag
it up to the full screen.
Here, we added a grabber on top of the
sheet, so users can understand how to
drag it & drag it.
When the bottom sheet is presented, the
view behind it dims automatically; if you
want to prevent it, you can set the value
of largestUndimmedDetentIdentifier to
.medium.
bSheet.largestUndimmedDetentIdentifie
r = .medium


If your bottom sheet has scrollable
content, we can set
prefersScrollingExpandsWhenScroll
edToEdge to false so that it will
scroll without going down & using
grabber; you can drag the sheet &
show it in full screen.
bSheet.prefersScrollingExpandsWh
enScrolledToEdge = false
We can set the corner radius for the
bottom sheet also using
preferredCornerRadius.
bSheet.preferredCornerRadius =
30.0


Want to get dedicated and highly-
skilled iOS developers?
Contact the best mobile
development company: Bacancy,
to hire iOS developer and start
building brilliant mobile apps.
2. UIMenu:


iOS 14 introduced UIMenu, but if you
want to add a submenu, it was not
possible in iOS 14. So, iOS 15
introduced UIMenu with SubMenu
added to it.


Using UIMenu, we can create an
instance of the menu; it has a
parameter called children that can
take an array of UIMenu & UIAction.


UIAction takes the title, image,
attributes, state & handler as its
parameters.
UIMenu takes the title, image, options,
handler & other parameters. The state
in
UIAction is used to show a checkmark
to show selection.


It has 3 values .displayInline,
.destructive, .singleSelection. Using the
.singleSelection or .destructive option in
UIMenu, we can show the submenu.
When using .singleSelection It will allow
only 1 item as selected in the menu or
submenu.
@IBAction func menuAction(_ sender
: UIButton) {
let more = UIMenu(title: "More",
image: UIImage(systemName:
"ellipsis"), options: .singleSelection,
children: [
UIAction(title: "Share", image:
UIImage(systemName:
"square.and.arrow.up"), handler: { _ in
}),
UIAction(title: "Save", image:
UIImage(systemName: "folder"),
handler: { _ in }),
UIAction(title: "Edit", image:
UIImage(systemName: "pencil"),
state: .on, handler: { _ in })
])
let destruct = UIAction(title: "Delete",
image: UIImage(systemName:
"trash"), attributes: .destructive) { _
in }
let disable = UIAction(title:
"Standard", image:
UIImage(systemName: "sun.max"),
attributes: .disabled) { _ in }
btnMenu.menu = UIMenu(title:
"", children: [more, destruct, disable])
}
On long pressing the button, it shows the
menu; if you want to open the menu by
tapping the button, you can use the
property showsMenuAsPrimaryAction.


btnMenu.showsMenuAsPrimaryActi
on = true
3.CLLocationButton
In iOS 13, new location permission was
introduced to access it only once. So,
whenever a user tries to access the
location, it asks for permission. In iOS
15, Apple improved that feature. They
are providing location button UI by
default. So, the first time it will ask the
user for permission. Whenever users
open the app again, the user can simply
click on the location button & it will
give access to the current location
without asking for permission alert.


If the user has denied permission for
the first time, when the user clicks on
the location button next time, it will
give access to the current location
without asking for a permission alert.
Once the location access is granted, even if
the application is in the background, it will
get location data. Location data access will
expire once the user or system terminates
the app.
4.Async/Await:


Swift 5.5 introduced changes in the
concurrency system using
async/await. Concurrency means
running multiple chunks of code at
the same time. As the name suggests,
it is a way to write complex
asynchronous code if it is
synchronous. There are two steps to
perform for async/await: make a
function using the async keyword &
call it using await keyword. Async
means asynchronous; we can add it as
method attributes.
func generateRandomNumbers()
async -> [Int] {
(1...100).map { _ in
Int.random(in: 1...100)
}
}


To call this method, we need to use
await keyword ahead of the method call
& add it in an asynchronous context,
Task.
func showNumbers() {
Task{
let numbers = await
generateRandomNumbers()
print(numbers)
}
}
Before async/await was
introduced, we used closure
completion blocks, Result mostly
in Web service calls. From swift 5.5
onwards, We can use async/await
for asynchronous code without
completion handlers to return
values. We can directly assign
those values to
their respective variables. Using await
keyword in a function call will stop
further code execution until a response
comes.
To execute further code while
asynchronous code is executing, you
can keep the async keyword before the
variable & await the keyword while
accessing its result.
async let numbers =
generateRandomNumbers()
print(await numbers)
If we want to call multiple asynchronous
functions parallel, we can also do it with
async/await.
async let numbersInt =
generateRandomNumbersInt()
async let numbersDouble =
generateRandomNumbersDouble()
let numbers = await [numbersInt,
numbersDouble] as [Any]
print(numbers)


For error handling, in async/await, we
can use Result or try/catch.
let result = await
generateRandomNumbersInt()
switch result {
case .success(_):
break
case .failure(_):
break
}
do {
let result = try await
generateRandomNumbersInt()
print(result)
} catch let e {
print(e)
}
5. Double & CGFloat Interchangeable
Types:


From swift 5.5, You can use Double &
CGFloat interchangeably without
converting them.
You can perform operations on Double
& CGFloat & can get the result in
Double.


let varCgFloat: CGFloat = 40
let varDouble: Double = 80
let result = varCgFloat + varDouble
print(result)
Output::
6. Lazy in the Local Context


Lazy keywords allow us to define stored
properties that will initialize when first
time used. From Swift 5.5, you can now
use the lazy keyword in the local context.
func printGreetingMethod(to: String)
-> String {
print("In printGreetingMethod()")
return "Hey, (to)"
}
func lazyInLocal() {
print("Before lazy call")
lazy var greetingLazy =
printGreetingMethod(to: "jena")
print("After lazy call")
print(greetingLazy)
}
Output:
Conclusion
With the introduction of new
features in iOS 15 and Swift 5.5, the
application development became
less challenging with more robust
outcomes. The lightweight and
straightforward syntax with
powerful pattern matching has
made development better for iOS
developers.
Thank You
https://www.bacancytechnology.com/

Recommandé

How to create ui using droid draw par
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
7K vues12 diapositives
Android tutorials7 calculator par
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculatorVlad Kolesnyk
2.8K vues23 diapositives
IOS Swift language 1st Tutorial par
IOS Swift language 1st TutorialIOS Swift language 1st Tutorial
IOS Swift language 1st TutorialHassan A-j
424 vues85 diapositives
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists par
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsMobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsAndiNurkholis1
175 vues17 diapositives
Calculator 1 par
Calculator 1Calculator 1
Calculator 1livecode
1.1K vues20 diapositives
Android app development par
Android app developmentAndroid app development
Android app developmentVara Prasad Kanakam
203 vues22 diapositives

Contenu connexe

Similaire à New Features in iOS 15 and Swift 5.5.pdf

Project two c++ tutorial par
Project two c++ tutorialProject two c++ tutorial
Project two c++ tutorialBabatunde Salaam
690 vues13 diapositives
Ruby motion勉強会 2012年7月 par
Ruby motion勉強会 2012年7月Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月Eihiro Saishu
1.3K vues50 diapositives
Creating an Uber Clone - Part XXVIII - Transcript.pdf par
Creating an Uber Clone - Part XXVIII - Transcript.pdfCreating an Uber Clone - Part XXVIII - Transcript.pdf
Creating an Uber Clone - Part XXVIII - Transcript.pdfShaiAlmog1
264 vues11 diapositives
Gui builder par
Gui builderGui builder
Gui builderlearnt
430 vues6 diapositives
Android, the life of your app par
Android, the life of your appAndroid, the life of your app
Android, the life of your appEyal Lezmy
640 vues72 diapositives
Easy job scheduling with android par
Easy job scheduling with androidEasy job scheduling with android
Easy job scheduling with androidkirubhakarans2
208 vues9 diapositives

Similaire à New Features in iOS 15 and Swift 5.5.pdf(20)

Ruby motion勉強会 2012年7月 par Eihiro Saishu
Ruby motion勉強会 2012年7月Ruby motion勉強会 2012年7月
Ruby motion勉強会 2012年7月
Eihiro Saishu1.3K vues
Creating an Uber Clone - Part XXVIII - Transcript.pdf par ShaiAlmog1
Creating an Uber Clone - Part XXVIII - Transcript.pdfCreating an Uber Clone - Part XXVIII - Transcript.pdf
Creating an Uber Clone - Part XXVIII - Transcript.pdf
ShaiAlmog1264 vues
Gui builder par learnt
Gui builderGui builder
Gui builder
learnt430 vues
Android, the life of your app par Eyal Lezmy
Android, the life of your appAndroid, the life of your app
Android, the life of your app
Eyal Lezmy640 vues
How to create_your_own_android_app par Charo Cuart
How to create_your_own_android_appHow to create_your_own_android_app
How to create_your_own_android_app
Charo Cuart327 vues
Cucumber meets iPhone par Erin Dees
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
Erin Dees19.9K vues
Angular Interview Questions-PDF.pdf par JohnLeo57
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
JohnLeo5735 vues
Creating an Uber Clone - Part I - Transcript.pdf par ShaiAlmog1
Creating an Uber Clone - Part I - Transcript.pdfCreating an Uber Clone - Part I - Transcript.pdf
Creating an Uber Clone - Part I - Transcript.pdf
ShaiAlmog1286 vues
21 android2 updated par GhanaGTUG
21 android2 updated21 android2 updated
21 android2 updated
GhanaGTUG2.6K vues

Plus de Katy Slemon

Data Science Use Cases in Retail & Healthcare Industries.pdf par
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfKaty Slemon
117 vues37 diapositives
How Much Does It Cost To Hire Golang Developer.pdf par
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfKaty Slemon
78 vues31 diapositives
What’s New in Flutter 3.pdf par
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfKaty Slemon
85 vues24 diapositives
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf par
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfKaty Slemon
72 vues36 diapositives
How to Implement Middleware Pipeline in VueJS.pdf par
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfKaty Slemon
116 vues32 diapositives
How to Build Laravel Package Using Composer.pdf par
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfKaty Slemon
68 vues32 diapositives

Plus de Katy Slemon(20)

Data Science Use Cases in Retail & Healthcare Industries.pdf par Katy Slemon
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
Katy Slemon117 vues
How Much Does It Cost To Hire Golang Developer.pdf par Katy Slemon
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
Katy Slemon78 vues
What’s New in Flutter 3.pdf par Katy Slemon
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
Katy Slemon85 vues
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf par Katy Slemon
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
Katy Slemon72 vues
How to Implement Middleware Pipeline in VueJS.pdf par Katy Slemon
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
Katy Slemon116 vues
How to Build Laravel Package Using Composer.pdf par Katy Slemon
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
Katy Slemon68 vues
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf par Katy Slemon
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Katy Slemon53 vues
How to Develop Slack Bot Using Golang.pdf par Katy Slemon
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
Katy Slemon75 vues
IoT Based Battery Management System in Electric Vehicles.pdf par Katy Slemon
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
Katy Slemon931 vues
Understanding Flexbox Layout in React Native.pdf par Katy Slemon
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
Katy Slemon128 vues
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf par Katy Slemon
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
Katy Slemon178 vues
Choose the Right Battery Management System for Lithium Ion Batteries.pdf par Katy Slemon
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Katy Slemon117 vues
Angular Universal How to Build Angular SEO Friendly App.pdf par Katy Slemon
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
Katy Slemon110 vues
Ruby On Rails Performance Tuning Guide.pdf par Katy Slemon
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
Katy Slemon122 vues
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf par Katy Slemon
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Katy Slemon39 vues
Unit Testing Using Mockito in Android (1).pdf par Katy Slemon
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdf
Katy Slemon115 vues
Why Use React Js A Complete Guide (1).pdf par Katy Slemon
Why Use React Js A Complete Guide (1).pdfWhy Use React Js A Complete Guide (1).pdf
Why Use React Js A Complete Guide (1).pdf
Katy Slemon161 vues
Why Use Ruby on Rails for eCommerce Project Proven Case Study.pdf par Katy Slemon
Why Use Ruby on Rails for eCommerce Project Proven Case Study.pdfWhy Use Ruby on Rails for eCommerce Project Proven Case Study.pdf
Why Use Ruby on Rails for eCommerce Project Proven Case Study.pdf
Katy Slemon535 vues
Bacancy’s CCS2CON is Now Charging Compliant with Top Indian EVs.pdf par Katy Slemon
Bacancy’s CCS2CON is Now Charging Compliant with Top Indian EVs.pdfBacancy’s CCS2CON is Now Charging Compliant with Top Indian EVs.pdf
Bacancy’s CCS2CON is Now Charging Compliant with Top Indian EVs.pdf
Katy Slemon71 vues
How to Integrate Google Adwords API in Laravel App.pdf par Katy Slemon
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
Katy Slemon426 vues

Dernier

Roadmap to Become Experts.pptx par
Roadmap to Become Experts.pptxRoadmap to Become Experts.pptx
Roadmap to Become Experts.pptxdscwidyatamanew
14 vues45 diapositives
Transcript: The Details of Description Techniques tips and tangents on altern... par
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...BookNet Canada
135 vues15 diapositives
Top 10 Strategic Technologies in 2024: AI and Automation par
Top 10 Strategic Technologies in 2024: AI and AutomationTop 10 Strategic Technologies in 2024: AI and Automation
Top 10 Strategic Technologies in 2024: AI and AutomationAutomationEdge Technologies
18 vues14 diapositives
20231123_Camunda Meetup Vienna.pdf par
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
33 vues73 diapositives
Microsoft Power Platform.pptx par
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptxUni Systems S.M.S.A.
52 vues38 diapositives
SAP Automation Using Bar Code and FIORI.pdf par
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
22 vues38 diapositives

Dernier(20)

Transcript: The Details of Description Techniques tips and tangents on altern... par BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada135 vues
Empathic Computing: Delivering the Potential of the Metaverse par Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Case Study Copenhagen Energy and Business Central.pdf par Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 vues
DALI Basics Course 2023 par Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 vues
6g - REPORT.pdf par Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex10 vues
Five Things You SHOULD Know About Postman par Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman30 vues
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors par sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 vues
Voice Logger - Telephony Integration Solution at Aegis par Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma31 vues
Attacking IoT Devices from a Web Perspective - Linux Day par Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 vues
Lilypad @ Labweek, Istanbul, 2023.pdf par Ally339821
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdf
Ally3398219 vues
Piloting & Scaling Successfully With Microsoft Viva par Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva

New Features in iOS 15 and Swift 5.5.pdf

  • 1. New Features in iOS 15 and Swift 5.5 https://www.bacancytechnology.com/
  • 4. At Worldwide Developers Conference 21, Apple has overcome many limitations by announcing some important features for developers. Apple has made sure while introducing the new features in iOS 15 and Swift 5.5 that every developer can build the best interactive applications with minimal time and effort. In this blog post, we will learn a few new features that have been introduced and see how we can implement them in our code.
  • 5. New Features in iOS 15 and Swift 5.5
  • 6. 1. UISheetPresentation Controller Apple provided some new API improvements in WWDC 21 to present the bottom sheets. In iOS 14, they introduced this, but it didn’t have any customization, but from iOS 15, we can implement apple maps like a bottom sheet with a smaller height. It has customization like height adjustment, adding a grabber to the top of the sheet. UIViewController has a new property called sheetPresentationController; you can present the bottom sheet. We can access the sheetPresentationController property to get the instance of UISheetPresentationController for customizing its appearance.
  • 7. @IBAction func openSheetAction(_ sender : UIButton) { if let bSheet = bottomSheet.sheetPresentationController { bSheet.detents = [.medium(), .large()] bSheet.prefersGrabberVisible = true bSheet.largestUndimmedDetentIdentifie r = .medium bSheet.prefersScrollingExpandsWhenScr olledToEdge = false bSheet.preferredCornerRadius = 30.0 } present(bottomSheet, animated: true, completion: nil) }
  • 8. Here, we can use detents to adjust the height of the bottom sheet. It has 2 values .large() & .medium(). .large() will show height for full screen & .medium() will occupy height of half of screen height. Here, We have passed an array for detents, so first, it will show in half of the screen height & then we can drag it up to the full screen.
  • 9. Here, we added a grabber on top of the sheet, so users can understand how to drag it & drag it. When the bottom sheet is presented, the view behind it dims automatically; if you want to prevent it, you can set the value of largestUndimmedDetentIdentifier to .medium.
  • 10. bSheet.largestUndimmedDetentIdentifie r = .medium If your bottom sheet has scrollable content, we can set prefersScrollingExpandsWhenScroll edToEdge to false so that it will scroll without going down & using grabber; you can drag the sheet & show it in full screen. bSheet.prefersScrollingExpandsWh enScrolledToEdge = false
  • 11. We can set the corner radius for the bottom sheet also using preferredCornerRadius. bSheet.preferredCornerRadius = 30.0 Want to get dedicated and highly- skilled iOS developers? Contact the best mobile development company: Bacancy, to hire iOS developer and start building brilliant mobile apps.
  • 12. 2. UIMenu: iOS 14 introduced UIMenu, but if you want to add a submenu, it was not possible in iOS 14. So, iOS 15 introduced UIMenu with SubMenu added to it. Using UIMenu, we can create an instance of the menu; it has a parameter called children that can take an array of UIMenu & UIAction. UIAction takes the title, image, attributes, state & handler as its parameters.
  • 13. UIMenu takes the title, image, options, handler & other parameters. The state in UIAction is used to show a checkmark to show selection. It has 3 values .displayInline, .destructive, .singleSelection. Using the .singleSelection or .destructive option in UIMenu, we can show the submenu. When using .singleSelection It will allow only 1 item as selected in the menu or submenu.
  • 14. @IBAction func menuAction(_ sender : UIButton) { let more = UIMenu(title: "More", image: UIImage(systemName: "ellipsis"), options: .singleSelection, children: [ UIAction(title: "Share", image: UIImage(systemName: "square.and.arrow.up"), handler: { _ in }), UIAction(title: "Save", image: UIImage(systemName: "folder"), handler: { _ in }), UIAction(title: "Edit", image: UIImage(systemName: "pencil"), state: .on, handler: { _ in }) ])
  • 15. let destruct = UIAction(title: "Delete", image: UIImage(systemName: "trash"), attributes: .destructive) { _ in } let disable = UIAction(title: "Standard", image: UIImage(systemName: "sun.max"), attributes: .disabled) { _ in } btnMenu.menu = UIMenu(title: "", children: [more, destruct, disable]) }
  • 16. On long pressing the button, it shows the menu; if you want to open the menu by tapping the button, you can use the property showsMenuAsPrimaryAction. btnMenu.showsMenuAsPrimaryActi on = true
  • 17. 3.CLLocationButton In iOS 13, new location permission was introduced to access it only once. So, whenever a user tries to access the location, it asks for permission. In iOS 15, Apple improved that feature. They are providing location button UI by default. So, the first time it will ask the user for permission. Whenever users open the app again, the user can simply click on the location button & it will give access to the current location without asking for permission alert. If the user has denied permission for the first time, when the user clicks on the location button next time, it will give access to the current location
  • 18. without asking for a permission alert. Once the location access is granted, even if the application is in the background, it will get location data. Location data access will expire once the user or system terminates the app.
  • 19. 4.Async/Await: Swift 5.5 introduced changes in the concurrency system using async/await. Concurrency means running multiple chunks of code at the same time. As the name suggests, it is a way to write complex asynchronous code if it is synchronous. There are two steps to perform for async/await: make a function using the async keyword & call it using await keyword. Async means asynchronous; we can add it as method attributes.
  • 20. func generateRandomNumbers() async -> [Int] { (1...100).map { _ in Int.random(in: 1...100) } } To call this method, we need to use await keyword ahead of the method call & add it in an asynchronous context, Task.
  • 21. func showNumbers() { Task{ let numbers = await generateRandomNumbers() print(numbers) } } Before async/await was introduced, we used closure completion blocks, Result mostly in Web service calls. From swift 5.5 onwards, We can use async/await for asynchronous code without completion handlers to return values. We can directly assign those values to
  • 22. their respective variables. Using await keyword in a function call will stop further code execution until a response comes. To execute further code while asynchronous code is executing, you can keep the async keyword before the variable & await the keyword while accessing its result. async let numbers = generateRandomNumbers() print(await numbers)
  • 23. If we want to call multiple asynchronous functions parallel, we can also do it with async/await. async let numbersInt = generateRandomNumbersInt() async let numbersDouble = generateRandomNumbersDouble() let numbers = await [numbersInt, numbersDouble] as [Any] print(numbers) For error handling, in async/await, we can use Result or try/catch.
  • 24. let result = await generateRandomNumbersInt() switch result { case .success(_): break case .failure(_): break } do { let result = try await generateRandomNumbersInt() print(result) } catch let e { print(e) }
  • 25. 5. Double & CGFloat Interchangeable Types: From swift 5.5, You can use Double & CGFloat interchangeably without converting them. You can perform operations on Double & CGFloat & can get the result in Double. let varCgFloat: CGFloat = 40 let varDouble: Double = 80 let result = varCgFloat + varDouble print(result)
  • 26. Output:: 6. Lazy in the Local Context Lazy keywords allow us to define stored properties that will initialize when first time used. From Swift 5.5, you can now use the lazy keyword in the local context.
  • 27. func printGreetingMethod(to: String) -> String { print("In printGreetingMethod()") return "Hey, (to)" } func lazyInLocal() { print("Before lazy call") lazy var greetingLazy = printGreetingMethod(to: "jena") print("After lazy call") print(greetingLazy) }
  • 30. With the introduction of new features in iOS 15 and Swift 5.5, the application development became less challenging with more robust outcomes. The lightweight and straightforward syntax with powerful pattern matching has made development better for iOS developers.