#swiftuitutorials
Explore tagged Tumblr posts
Photo

SwiftUI 4.0 App Walkthrough Screens - Onboarding Screen . https://www.boltuix.com/2022/08/how-to-create-onboarding-with-swiftui.html #swiftui #swiftuitutorials #swiftuiappdevelopment #swiftuitutorials #swiftuiapp #swiftuidev #swiftui3 #swiftui4 #swiftuiprogramming #swiftuibeginner #swiftuimasterclass #swiftuiexample #iosapp #iosappdevelopment #iosapps #uiux #uiuxdesign #uiuxdesigner https://www.instagram.com/p/ChVFzjCP7lY/?igshid=NGJjMDIxMWI=
#swiftui#swiftuitutorials#swiftuiappdevelopment#swiftuiapp#swiftuidev#swiftui3#swiftui4#swiftuiprogramming#swiftuibeginner#swiftuimasterclass#swiftuiexample#iosapp#iosappdevelopment#iosapps#uiux#uiuxdesign#uiuxdesigner
1 note
·
View note
Video
Credits to @inncoder_ Recreated @olegdesignfrolov 's animation using #swiftui Go check him out! #inncoder #swift #mobiledeveloper #ios #iosdeveloper #dev #programming #tech #apple #coding #xcode #iosdesign #iosdevelopment #appdeveloper #appdevelopment #developerlife #programminglife #swiftlang #ui #ux #appdesign #uidesign #code #coder #swiftdev #swiftdeveloper #swiftuitutorials #microinteractions Reposted from @inncoder_ https://www.instagram.com/p/CNn86ZkgQAs/?igshid=siaf8vs1y5s3
#swiftui#inncoder#swift#mobiledeveloper#ios#iosdeveloper#dev#programming#tech#apple#coding#xcode#iosdesign#iosdevelopment#appdeveloper#appdevelopment#developerlife#programminglife#swiftlang#ui#ux#appdesign#uidesign#code#coder#swiftdev#swiftdeveloper#swiftuitutorials#microinteractions
0 notes
Text
How to create and combine views in SwiftUI
How to create and combine views in SwiftUI
This tutorial follows the Apple Developer demo app for creating and combining views in SwiftUI. Let’s play with SwiftUI.
Create a new SwiftUI Project
Open Xcode, and select Create a new Xcode project.
Under iOS, select Single View App and click Next button.
In the next window, give Product Name as SwiftUITutorial. Make sure SwiftUI is selected in User Interface dropdown. Click Next.
View On WordPress
0 notes
Text
SwiftUI MapKit Tutorial
At the time of writing MapKit can only be used with SwiftUI by using the UIViewRepresentable protocol. Using Map Kit, the portion of the map that is displayed on the screen is referred to as the region. The region is defined by a center location and a span of the surrounding area to be displayed. Inside the Map View an annotation could be created, indication a Point of Interest. In this tutorial we will display a portion of the city London and we will add an annotation of the Big Ben. SwiftUI requires Xcode 11 and MacOS Catalina, which can be download at the Apple developer portal.
Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project. In the template selector, select iOS as the platform, select the Single View App template, and then click Next. Enter SwiftUIMapKitTutorial as the Product Name, select the Use SwiftUI checkbox, and click Next. Choose a location to save the project on your Mac.
In the canvas, click Resume to display the preview. If the canvas isn’t visible, select Editor > Editor and Canvas to show it.
In the Project navigator, click to select ContentView.swift. Import the MapKit framework.
import MapKit
Add the MapView struct.
struct MapView: UIViewRepresentable { // 1. func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView { MKMapView(frame: .zero) } // 2. func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapView>) { // 3. let location = CLLocationCoordinate2D(latitude: 51.50007773, longitude: -0.1246402) // 4. let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) let region = MKCoordinateRegion(center: location, span: span) uiView.setRegion(region, animated: true) // 5. let annotation = MKPointAnnotation() annotation.coordinate = location annotation.title = "Big Ben" annotation.subtitle = "London" uiView.addAnnotation(annotation) } }
The makeUIView(context:) method is creates an empty Map View.
The updateUI(context:) method updated the Map View
The latitude and longitude of the city of London is assigned to location constant using the CLLocationCoordinate2d struct
The span value is made relative small, so a big portion of London is visible. The MKCoordinateRegion method defines the visible region, it is set with the setRegion method.
An annotation is created at the current coordinates with the MKPointAnnotation class. The annotation is added to the Map View with the addAnnotation method.
Change the code inside the ContentView struct to
struct ContentView: View { var body: some View { NavigationView { MapView() .navigationBarTitle(Text("Map View")) } } }
The Map View is displayed inside a Navigation View. Go to the preview Window and select the Live Preview button. The Preview will look like this.
The source code of the SwiftUITutorial can be downloaded at the ioscreator repository on Github.
0 notes
Text
SwiftUI Customize Navigation Bar Tutorial
Most part of the navigation bar can be customized using the appearance protocol, such as the title, background and the navigation bar items .In this tutorial a navigation view containing a list will be displayed and customized . SwiftUI requires Xcode 11 and MacOS Catalina, which the can be downloadat the Apple developer portal.
Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project. In the template selector, select iOS as the platform, select the Single View App template, and then click Next. Enter SwiftUICustomizeNavBarTutorial as the Product Name, select the Use SwiftUI checkbox, and click Next. Choose a location to save the project on your Mac.
In the canvas, click Resume to display the preview. If the canvas isn’t visible, select Editor > Editor and Canvas to show it.
In the Project navigator, click to select ContentView.swift. Change the code inside the ContentView.file to
import SwiftUI // 1. struct People: Identifiable{ var id = UUID() var name = String() } struct ContentView: View { // 2. let people: [People] = [ People(name: "Bill"), People(name: "Jacob"), People(name: "Olivia")] var body: some View { NavigationView { // 3. List(people) { listedPeople in NavigationLink(destination: DetailView(name: listedPeople.name)) { VStack(alignment: .leading){ Text(listedPeople.name) } } } // 4. .navigationBarItems(leading: HStack { Button(action: {}) { Image(systemName: "minus.square.fill") .font(.largeTitle) }.foregroundColor(.pink) }, trailing: HStack { Button(action: {}) { Image(systemName: "plus.square.fill") .font(.largeTitle) }.foregroundColor(.blue) }) // 5. .navigationBarTitle(Text("Names")) } } } // 6. struct DetailView: View { var name: String var body: some View { Text("current name is: \(name) ") // 7. .navigationBarTitle(Text("Current Name"), displayMode: .inline) } }
The people struct will be used as the model for the items in the list.
an array of people is declared
A list is displayed, when a row is selected the detail view is displayed containing the current selected name.
Two navigation bar items are declared containing a system image each with a custom color.
The navigation bar title is displayed
The detailview struct will display the current selected name
The navigation bar style is set to .inline
The preview will look like this.
To apply more customization to the navigation bar, the appearance protocol can be used. Add the init() method to the ContentView struct.
init() { // 1. UINavigationBar.appearance().backgroundColor = .yellow // 2. UINavigationBar.appearance().largeTitleTextAttributes = [ .foregroundColor: UIColor.darkGray, .font : UIFont(name:"Papyrus", size: 40)!] // 3. UINavigationBar.appearance().titleTextAttributes = [ .font : UIFont(name: "HelveticaNeue-Thin", size: 20)!] }
The background color of the navigation bar is set to yellow
A custom font with a size of 40 points and a dark grey color is applied to the “large” style.
A custom font with a size of 20 points is applied to the “lnline” style.
Go to the preview pane and click the live preview button. The Navigation Bar in the content view is customized,
Click a name in the list to view the detail view.
The source code of the SwiftUITutorial can be downloaded at the ioscreator repository on Github.
0 notes
Text
SwiftUI EnvironmentObject Tutorial
@EnvironmentObject can be used to share data between all views and to auto-update those views when the data changes In this tutorial a property is created and shared between views . SwiftUI requires Xcode 11 and MacOS Catalina, for which the Betas can be downloaded at the Apple developer portal.
Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project. In the template selector, select iOS as the platform, select the Single View App template, and then click Next. Enter SwiftUIEnvironmentObjectTutorial as the Product Name, select the Use SwiftUI checkbox, and click Next. Choose a location to save the project on your Mac.
Go to the ContentView.swift file and add the following class to the file
class GameSettings: ObservableObject { @Published var score: Int = 0 }
Go to the SceneDelegate.swift file and add the following property
var settings = GameSettings()
Add the settings property as a parameter to the environmentObject function of the contentView.
if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) window.rootViewController = UIHostingController(rootView: contentView.environmentObject(settings)) self.window = window window.makeKeyAndVisible() }
Go back to the ContentView.swift file. In the canvas, click Resume to display the preview. If the canvas isn’t visible, select Editor > Editor and Canvas to show it.
Change the code inside the ContentView struct to
struct ContentView: View { // 1. @EnvironmentObject var settings: GameSettings var body: some View { NavigationView { VStack { // 2. Stepper(value: $settings.score, in: 1...1000000, step: 1000, label: { Text("Current Score: \(settings.score)") }).padding() // 3. NavigationLink(destination: ScoreView()) { Text("Show Current Score") } } } } }
The EnvironmentObject property watches and updates the settings value.
A stepper is displayed which can be used to change the score.
The scoreView( ) struct will be called to show the current score.
Add the scoreView struct.
struct ScoreView: View { @EnvironmentObject var settings: GameSettings var body: some View { Text("Score: \(settings.score)") } }
The ScoreView will display the current score. Go to the preview, and click the Live mode button. Change the score with the stepper and click the “Show current score” text. The score value is also updated in the ScoreView.
The preview will look like this.
The source code of the SwiftUITutorial can be downloaded at the ioscreator repository on Github.
0 notes
Text
SwiftUI Stepper Tutorial
The UIStepper control provides a simple way to change a numeral value. It consists of +/- symbols that increment/decrement an internal value. In this tutorial we will change the value of a Text view using the UIStepper buttons. SwiftUI requires Xcode 11 and MacOS Catalina, for which the Betas can be downloaded at the Apple developer portal.
Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project. In the template selector, select iOS as the platform, select the Single View App template, and then click Next. Enter SwiftUITutorial as the Product Name, select the Use SwiftUI checkbox, and click Next. Choose a location to save the project on your Mac.
In the canvas, click Resume to display the preview. If the canvas isn’t visible, select Editor > Editor and Canvas to show it.
In the Project navigator, click to select ContentView.swift. Change the code inside the ContentView struct to
struct ContentView: View { // 1. @State var numberOfItems: Int = 0 var body: some View { // 2. Stepper(value: $numberOfItems, in: 0...10, label: { Text("Number of items: \(numberOfItems)")}).padding() } }
A State property is declared. The initial value of the stepper is 0.
A Stepper is displayed with a value of 0 to 10. The current stepper value will be displayed in a text view.
Go to the preview pane and go to live mode. Change the stepper value and the text will change with the current value.
The source code of the SwiftUIStepperTutorial can be downloaded at the ioscreator repository on Github.
0 notes