contributors |
---|
zntfdr |
-
New quick authorization button:
CLLocationButton
for UIKitLocationButton
for SwiftUI
-
these buttons give your app Allow-Once authorization, without prompting user authorization every time it's tapped
-
available on watchOS, iOS, macOS with Catalyst, and iPad apps on Mac
This is a UIButton with customizable parameters:
CLLocationButtonIcon
to set the type of the arrowCLLocationLabel
to set the label of the buttoncornerRadius
to set the roundness of the buttonfontSize
to set the size of the label
LocationButton(.currentLocation) {
// do something on button press...
}
.foregroundColor(.white)
.cornerRadius(15.0)
.labelStyle(.titleAndIcon)
.symbolVariant(.fill)
.tint(.blue)
Note that not all customization are possible, Xcode will warn you with log messages when the minimum requirements are not met, for example:
#locationButton rendering failed due to inappropriate sizes
#locationButton rendering failed due to Insufficient Alpha
#locationButton rendering failed due to contrastRatio between tintColor and backgroundColor insufficient
- If your app already have any kind of location authorization, then the button will work right away
- If your app doesn't have any permission yet, tapping the location button will trigger a one-time prompt (which won't be shown again when tapped again), see below
- this same prompt is shown if the user previously denied your app location permission access