Notes WWDC 2021 : Meet the Location Button
Mes notes pour la session Meet the Location Button de la WWDC 2021.
CLLoctionButton
: new way to request location authorization.
Gives the app “allow once” authorization without prompt.
Customizable, but with restrictions: will log a message for “inappropriate size”, “insufficient alpha” or “insufficient contrast ratio between tintColor and backgroundColor”.
let button = CLLocationButton()
button.label = .currentLocation
button.addTarget(self, action: #selector(showParks), for: .touchUpInside)
// ...
@objc func showParks() {
// Not needed, called by the button itself
// self.locationManager.requestWhenInUseAuthorization()
self.locationManager.startUpdatingLocation()
}
For SwiftUI, use LocationButton()