<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Export Locked - AppMakers.Dev</title>
	<atom:link href="https://appmakers.dev/category/export-locked/feed/" rel="self" type="application/rss+xml" />
	<link>https://appmakers.dev/category/export-locked/</link>
	<description>SwiftUI Tutorials, iOS App Development, SwiftUI, Swift</description>
	<lastBuildDate>Fri, 18 Oct 2024 12:46:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://appmakers.dev/wp-content/uploads/2024/10/cropped-AppMakersDev-32x32.jpg</url>
	<title>Export Locked - AppMakers.Dev</title>
	<link>https://appmakers.dev/category/export-locked/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Semantic Colors in SwiftUI: accentColor, primary, secondary, custom color</title>
		<link>https://appmakers.dev/semantic-colors-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Wed, 19 Jun 2024 18:32:42 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Drawing and Animation]]></category>
		<category><![CDATA[SwiftUI Styling and Customization]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=567</guid>

					<description><![CDATA[<p>SwiftUI offers a variety of semantic colors that adapt to different contexts and system settings, enhancing the visual consistency and accessibility of your app. Semantic colors automatically adjust to the system&#8217;s color scheme and user preferences, making your app look great in both light and dark modes. This tutorial will guide you through using semantic&#8230;</p>
<p>The post <a href="https://appmakers.dev/semantic-colors-in-swiftui/">Semantic Colors in SwiftUI: accentColor, primary, secondary, custom color</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI offers a variety of semantic colors that adapt to different contexts and system settings, enhancing the visual consistency and accessibility of your app. Semantic colors automatically adjust to the system&#8217;s color scheme and user preferences, making your app look great in both light and dark modes. This tutorial will guide you through using semantic colors in SwiftUI with unique and engaging examples.</p>
<h2>Introduction to Semantic Colors</h2>
<p>Semantic colors are predefined colors in SwiftUI that adapt to the app&#8217;s theme and accessibility settings. Some common semantic colors include <code class="" data-line="">accentColor</code>, <code class="" data-line="">primary</code>, and <code class="" data-line="">secondary</code>.</p>
<h3>Example: Using AccentColor</h3>
<p>The <code class="" data-line="">accentColor</code> is a broad theme color applied to views and controls. You can set it at the application level by specifying an accent color in your app’s asset catalog.</p>
<h4>Setting AccentColor in Asset Catalog</h4>
<ol>
<li>Open your asset catalog (Assets.xcassets).</li>
<li>Create a new color set and name it <code class="" data-line="">AccentColor</code>.</li>
<li>Choose your desired color.</li>
</ol>
<h4>Example: Using AccentColor in SwiftUI</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

@main
struct SemanticColorsApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .accentColor(.purple) // Set accent color for the entire app
        }
    }
}

struct ContentView: View {
    var body: some View {
        VStack {
            Text(&quot;Accent Color Example&quot;)
                .foregroundStyle(Color.accentColor)
                .padding()
                .background(Color.accentColor.opacity(0.2))
                .cornerRadius(10)
            
            Button(action: {
                print(&quot;Button tapped&quot;)
            }) {
                Text(&quot;Tap Me&quot;)
                    .padding()
                    .background(Color.accentColor)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}
</code></pre>
<p>In this example, we set the accent color of the entire app to purple using the <code class="" data-line="">accentColor</code> modifier. The <code class="" data-line="">Text</code> and <code class="" data-line="">Button</code>views use the accent color to create a consistent look.</p>
<h3>Example: Using Primary and Secondary Colors</h3>
<p>The <code class="" data-line="">primary</code> and <code class="" data-line="">secondary</code> colors are used for primary and secondary content, respectively. These colors adapt to the system&#8217;s color scheme and user settings.</p>
<h4>Example: Using Primary and Secondary Colors in SwiftUI</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct PrimarySecondaryColorsView: View {
    var body: some View {
        VStack(spacing: 20) {
            Text(&quot;Primary Color Example&quot;)
                .foregroundStyle(Color.primary)
                .padding()
                .background(Color.primary.opacity(0.2))
                .cornerRadius(10)

            Text(&quot;Secondary Color Example&quot;)
                .foregroundStyle(Color.secondary)
                .padding()
                .background(Color.secondary.opacity(0.2))
                .cornerRadius(10)

            Button(action: {
                print(&quot;Primary Button tapped&quot;)
            }) {
                Text(&quot;Primary Button&quot;)
                    .padding()
                    .background(Color.primary)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }

            Button(action: {
                print(&quot;Secondary Button tapped&quot;)
            }) {
                Text(&quot;Secondary Button&quot;)
                    .padding()
                    .background(Color.secondary)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}

</code></pre>
<p>In this example, we use <code class="" data-line="">Color.primary</code> and <code class="" data-line="">Color.secondary</code> to style text and buttons. These colors adapt to the system&#8217;s light and dark modes, providing a consistent and accessible user experience.</p>
<h3>Example: Customizing System Colors</h3>
<p>In addition to predefined semantic colors, you can customize colors in SwiftUI to create a unique look for your app. Custom colors can be defined in the asset catalog or directly in code.</p>
<h4>Example: Using Custom Colors</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct CustomColorsView: View {
    var body: some View {
        VStack(spacing: 20) {
            Text(&quot;Custom Color Example&quot;)
                .foregroundStyle(Color(&quot;CustomColor&quot;))
                .padding()
                .background(Color(&quot;CustomColor&quot;).opacity(0.2))
                .cornerRadius(10)

            Button(action: {
                print(&quot;Custom Color Button tapped&quot;)
            }) {
                Text(&quot;Custom Color Button&quot;)
                    .padding()
                    .background(Color(&quot;CustomColor&quot;))
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}

</code></pre>
<p>To use custom colors:</p>
<ol>
<li>Open your asset catalog (Assets.xcassets).</li>
<li>Create a new color set and name it <code class="" data-line="">CustomColor</code>.</li>
<li>Choose your desired color.</li>
</ol>
<p>In this example, we define a custom color in the asset catalog and use it in the <code class="" data-line="">Text</code> and <code class="" data-line="">Button</code> views.</p>
<h2>Conclusion</h2>
<p>Using semantic colors in SwiftUI allows you to create visually consistent and accessible user interfaces. By leveraging <code class="" data-line="">accentColor</code>, <code class="" data-line="">primary</code>, <code class="" data-line="">secondary</code>, and custom colors, you can ensure your app looks great across different themes and user settings.</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/semantic-colors-in-swiftui/">Semantic Colors in SwiftUI: accentColor, primary, secondary, custom color</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Mastering Focus in SwiftUI: Using .focused Modifier</title>
		<link>https://appmakers.dev/swiftui-focused/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Wed, 19 Jun 2024 16:32:58 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<category><![CDATA[SwiftUI User Interaction]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=563</guid>

					<description><![CDATA[<p>SwiftUI&#8217;s .focused modifier allows you to control and observe the focus state of your views. This is particularly useful for managing user input fields and ensuring a smooth user experience. In this tutorial, we&#8217;ll explore how to use the .focused modifier with unique and interesting examples that are simple to understand for developers of all&#8230;</p>
<p>The post <a href="https://appmakers.dev/swiftui-focused/">Mastering Focus in SwiftUI: Using .focused Modifier</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI&#8217;s <code class="" data-line="">.focused</code> modifier allows you to control and observe the focus state of your views. This is particularly useful for managing user input fields and ensuring a smooth user experience. In this tutorial, we&#8217;ll explore how to use the <code class="" data-line="">.focused</code> modifier with unique and interesting examples that are simple to understand for developers of all levels.</p>
<h2>Introduction to .focused</h2>
<p>The <code class="" data-line="">.focused</code> modifier binds the focus state of a view to a Boolean state value. When the bound value is true, the view receives focus; when false, it loses focus. This allows you to programmatically manage the focus state of your views.</p>
<h3>Basic Example</h3>
<p>Let&#8217;s start with a basic example where we manage the focus state of a <code class="" data-line="">TextField</code> in a form, including a visual indicator for when the field is focused.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct FocusedExampleView: View {
    @State private var username: String = &quot;&quot;
    @State private var password: String = &quot;&quot;
    @FocusState private var usernameFieldIsFocused: Bool
    @FocusState private var passwordFieldIsFocused: Bool
    @State private var showPasswordHint = false

    var body: some View {
        VStack(spacing: 20) {
            TextField(&quot;Username&quot;, text: $username)
                .focused($usernameFieldIsFocused)
                .padding()
                .background(usernameFieldIsFocused ? Color.yellow.opacity(0.3) : Color.clear)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(usernameFieldIsFocused ? Color.blue : Color.gray, lineWidth: 2)
                )

            SecureField(&quot;Password&quot;, text: $password)
                .focused($passwordFieldIsFocused)
                .padding()
                .background(passwordFieldIsFocused ? Color.yellow.opacity(0.3) : Color.clear)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(passwordFieldIsFocused ? Color.blue : Color.gray, lineWidth: 2)
                )

            if showPasswordHint {
                Text(&quot;Password must be at least 8 characters long.&quot;)
                    .foregroundColor(.red)
            }

            Button(&quot;Submit&quot;) {
                validateForm()
            }
            .padding()
            .background(Color.blue)
            .foregroundColor(.white)
            .cornerRadius(10)
        }
        .padding()
    }

    private func validateForm() {
        if username.isEmpty {
            usernameFieldIsFocused = true
        } else if password.count &lt; 8 {
            passwordFieldIsFocused = true
            showPasswordHint = true
        } else {
            showPasswordHint = false
            print(&quot;Form submitted&quot;)
        }
    }
}
</code></pre>
<h3>Explanation</h3>
<ol>
<li><strong>State Variables</strong>: We use <code class="" data-line="">@State</code> variables to store the input values for the username and password fields, and to manage the visibility of the password hint.</li>
<li><strong>FocusState</strong>: We use <code class="" data-line="">@FocusState</code> property wrappers to track the focus state of the username and password fields.</li>
<li><strong>TextField and SecureField</strong>: The <code class="" data-line="">TextField</code> for the username and the <code class="" data-line="">SecureField</code> for the password are each bound to their respective focus states using the <code class="" data-line="">.focused</code> modifier.</li>
<li><strong>Visual Indicators</strong>: We change the background color and border color of the fields to indicate when they are focused.</li>
<li><strong>Form Validation</strong>: The <code class="" data-line="">validateForm</code> function checks if the username is empty or if the password is less than 8 characters long. It sets the focus to the appropriate field and displays a hint if necessary.</li>
<li><strong>Submit Button</strong>: The &#8220;Submit&#8221; button triggers the form validation logic.</li>
</ol>
<h2>Advanced Example: Managing Multiple Focused Fields</h2>
<p>In a more complex form, you might need to manage multiple fields and their focus states. Let&#8217;s extend our example to include an email field and implement a more sophisticated focus management, with visual indicators for each field.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct AdvancedFocusedExampleView: View {
    @State private var username: String = &quot;&quot;
    @State private var email: String = &quot;&quot;
    @State private var password: String = &quot;&quot;
    @FocusState private var usernameFieldIsFocused: Bool
    @FocusState private var emailFieldIsFocused: Bool
    @FocusState private var passwordFieldIsFocused: Bool
    @State private var showPasswordHint = false

    var body: some View {
        VStack(spacing: 20) {
            TextField(&quot;Username&quot;, text: $username)
                .focused($usernameFieldIsFocused)
                .padding()
                .background(usernameFieldIsFocused ? Color.yellow.opacity(0.3) : Color.clear)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(usernameFieldIsFocused ? Color.blue : Color.gray, lineWidth: 2)
                )

            TextField(&quot;Email&quot;, text: $email)
                .focused($emailFieldIsFocused)
                .padding()
                .background(emailFieldIsFocused ? Color.yellow.opacity(0.3) : Color.clear)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(emailFieldIsFocused ? Color.blue : Color.gray, lineWidth: 2)
                )
                .keyboardType(.emailAddress)
                .autocapitalization(.none)

            SecureField(&quot;Password&quot;, text: $password)
                .focused($passwordFieldIsFocused)
                .padding()
                .background(passwordFieldIsFocused ? Color.yellow.opacity(0.3) : Color.clear)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(passwordFieldIsFocused ? Color.blue : Color.gray, lineWidth: 2)
                )

            if showPasswordHint {
                Text(&quot;Password must be at least 8 characters long.&quot;)
                    .foregroundColor(.red)
            }

            Button(&quot;Submit&quot;) {
                validateForm()
            }
            .padding()
            .background(Color.blue)
            .foregroundColor(.white)
            .cornerRadius(10)
        }
        .padding()
    }

    private func validateForm() {
        if username.isEmpty {
            usernameFieldIsFocused = true
        } else if !isValidEmail(email) {
            emailFieldIsFocused = true
        } else if password.count &lt; 8 {
            passwordFieldIsFocused = true
            showPasswordHint = true
        } else {
            showPasswordHint = false
            print(&quot;Form submitted&quot;)
        }
    }

    private func isValidEmail(_ email: String) -&gt; Bool {
        // Simple email validation
        let emailRegEx = &quot;[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}&quot;
        let emailPredicate = NSPredicate(format:&quot;SELF MATCHES %@&quot;, emailRegEx)
        return emailPredicate.evaluate(with: email)
    }
}
</code></pre>
<h3>Explanation</h3>
<ol>
<li><strong>Multiple Fields</strong>: We apply the same visual indicator logic to the username, email, and password fields.</li>
<li><strong>Form Validation</strong>: The validation logic ensures the correct field is focused based on the validation outcome.</li>
<li><strong>Email Field</strong>: The email field has its own focus state and visual indicators.</li>
</ol>
<p>By adding these visual cues, users can easily identify which field is currently active, enhancing the user experience.</p>
<h2>Conclusion</h2>
<p>Using the <code class="" data-line="">.focused</code> modifier in SwiftUI allows you to control and observe the focus state of your views, enhancing the user experience by managing input fields efficiently. By following these examples, you can implement sophisticated focus management in your SwiftUI applications.</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/swiftui-focused/">Mastering Focus in SwiftUI: Using .focused Modifier</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Mastering Canvas, GraphicsContext, and Styles in SwiftUI</title>
		<link>https://appmakers.dev/mastering-canvas-graphicscontext-and-styles-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Tue, 28 May 2024 14:36:58 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Drawing and Animation]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=559</guid>

					<description><![CDATA[<p>SwiftUI offers a rich set of tools for creating and customizing user interfaces. Among these are Canvas, GraphicsContext, Border, ForegroundStyle, and BackgroundStyle. This tutorial will guide you through the basics of these powerful features with unique and easy-to-follow examples. Introduction to Canvas Canvas is a view in SwiftUI that provides a drawing area for creating&#8230;</p>
<p>The post <a href="https://appmakers.dev/mastering-canvas-graphicscontext-and-styles-in-swiftui/">Mastering Canvas, GraphicsContext, and Styles in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI offers a rich set of tools for creating and customizing user interfaces. Among these are <code class="" data-line="">Canvas</code>, <code class="" data-line="">GraphicsContext</code>, <code class="" data-line="">Border</code>, <code class="" data-line="">ForegroundStyle</code>, and <code class="" data-line="">BackgroundStyle</code>. This tutorial will guide you through the basics of these powerful features with unique and easy-to-follow examples.</p>
<h2>Introduction to Canvas</h2>
<p><code class="" data-line="">Canvas</code> is a view in SwiftUI that provides a drawing area for creating custom graphics. It uses <code class="" data-line="">GraphicsContext</code> to draw shapes, images, and text.</p>
<h3>Example: Drawing with Canvas and GraphicsContext</h3>
<pre><code class="language-swift" data-line="">import SwiftUI

struct CanvasDrawingView: View {
    var body: some View {
        Canvas { context, size in
            context.draw(Text(&quot;Hello, SwiftUI!&quot;), at: CGPoint(x: size.width / 2, y: size.height / 2))
            
            let circle = Path(ellipseIn: CGRect(x: size.width / 4, y: size.height / 4, width: size.width / 2, height: size.height / 2))
            context.fill(circle, with: .color(.blue))
        }
        .frame(width: 300, height: 300)
        .border(Color.black, width: 2)
    }
}
</code></pre>
<p>In this example, we use <code class="" data-line="">Canvas</code> to draw text and a blue circle. The <code class="" data-line="">GraphicsContext</code> allows us to draw shapes and text at specific positions within the canvas.</p>
<h2>Using Border</h2>
<p>The <code class="" data-line="">border</code> modifier adds a border around a view. You can customize the border&#8217;s color, width, and style.</p>
<h3>Example: Applying a Border to a View</h3>
<pre><code class="language-swift" data-line="">struct BorderedView: View {
    var body: some View {
        Text(&quot;Bordered Text&quot;)
            .padding()
            .border(Color.red, width: 4)
    }
}
</code></pre>
<p>In this example, we add a red border around a text view.</p>
<h2>ForegroundStyle</h2>
<p><code class="" data-line="">ForegroundStyle</code> allows you to set the style for the foreground content of a view, such as text or shapes.</p>
<h3>Example: Using ForegroundStyle with Text</h3>
<pre><code class="language-swift" data-line="">struct ForegroundStyledView: View {
    var body: some View {
        Text(&quot;Stylized Text&quot;)
            .font(.largeTitle)
            .foregroundStyle(
                LinearGradient(
                    gradient: Gradient(colors: [.red, .orange]),
                    startPoint: .leading,
                    endPoint: .trailing
                )
            )
            .padding()
    }
}</code></pre>
<p>In this example, we use a linear gradient as the foreground style for the text, creating a smooth color transition.</p>
<h2>BackgroundStyle</h2>
<p><code class="" data-line="">BackgroundStyle</code> allows you to set the background style of a view.</p>
<pre><code class="language-swift" data-line="">struct BackgroundStyledView: View {
    var body: some View {
        Text(&quot;Stylized Background&quot;)
            .padding()
            .background(
                LinearGradient(
                    gradient: Gradient(colors: [.blue, .purple]),
                    startPoint: .top,
                    endPoint: .bottom
                )
            )
            .cornerRadius(10)
            .padding()
    }
}</code></pre>
<p>In this example:</p>
<ol>
<li>We apply a <code class="" data-line="">LinearGradient</code> as the background to a <code class="" data-line="">Text</code> view using the <code class="" data-line="">.background</code> modifier.</li>
<li>The gradient transitions from blue at the top to purple at the bottom.</li>
<li>We add a corner radius to the text view to give it rounded corners.</li>
</ol>
<h2>Conclusion</h2>
<p>SwiftUI&#8217;s <code class="" data-line="">Canvas</code>, <code class="" data-line="">GraphicsContext</code>, <code class="" data-line="">Border</code>, <code class="" data-line="">ForegroundStyle</code>, and <code class="" data-line="">BackgroundStyle</code> provide powerful tools for creating custom graphics and styling views. By understanding and using these features, you can enhance the visual appeal and functionality of your SwiftUI applications.</p>
<p>The post <a href="https://appmakers.dev/mastering-canvas-graphicscontext-and-styles-in-swiftui/">Mastering Canvas, GraphicsContext, and Styles in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Clipboard &#8211; Copy and Paste in SwiftUI</title>
		<link>https://appmakers.dev/clipboard-copy-and-paste-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Tue, 28 May 2024 13:43:01 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Navigation]]></category>
		<category><![CDATA[SwiftUI State Management and Data Flow]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=555</guid>

					<description><![CDATA[<p>SwiftUI provides simple and powerful APIs to interact with the system clipboard. You can easily copy text to the clipboard and retrieve text from it. Basic Usage: Copying Text to Clipboard Let&#8217;s start with a basic example where we copy a text string to the clipboard when a button is pressed. Example: Copying Text to&#8230;</p>
<p>The post <a href="https://appmakers.dev/clipboard-copy-and-paste-in-swiftui/">Clipboard &#8211; Copy and Paste in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI provides simple and powerful APIs to interact with the system clipboard. You can easily copy text to the clipboard and retrieve text from it.</p>
<h3>Basic Usage: Copying Text to Clipboard</h3>
<p>Let&#8217;s start with a basic example where we copy a text string to the clipboard when a button is pressed.</p>
<h4>Example: Copying Text to Clipboard</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct CopyTextView: View {
    @State private var textToCopy = &quot;Hello, SwiftUI!&quot;
    @State private var message = &quot;Tap the button to copy text&quot;

    var body: some View {
        VStack(spacing: 20) {
            Text(message)
                .padding()

            Text(textToCopy)
                .padding()
                .background(Color.gray.opacity(0.2))
                .cornerRadius(10)

            Button(action: {
                UIPasteboard.general.string = textToCopy
                message = &quot;Text copied to clipboard!&quot;
            }) {
                Text(&quot;Copy Text&quot;)
                    .padding()
                    .background(Color.blue)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}</code></pre>
<p>In this example:</p>
<ol>
<li>We define a <code class="" data-line="">@State</code> variable <code class="" data-line="">textToCopy</code> that holds the text we want to copy.</li>
<li>Another <code class="" data-line="">@State</code> variable <code class="" data-line="">message</code> is used to display the status message.</li>
<li>When the button is pressed, the text is copied to the clipboard using <code class="" data-line="">UIPasteboard.general.string</code>.</li>
</ol>
<h3>Combining Copy and Paste Functionality</h3>
<p>Let&#8217;s combine the copy and paste functionality into a single view.</p>
<h4>Example: Copy and Paste Text</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct CopyPasteTextView: View {
    @State private var textToCopy = &quot;Hello, SwiftUI!&quot;
    @State private var pastedText = &quot;Tap &#039;Paste&#039; to see clipboard text&quot;

    var body: some View {
        VStack(spacing: 20) {
            Text(&quot;Text to Copy:&quot;)
            Text(textToCopy)
                .padding()
                .background(Color.gray.opacity(0.2))
                .cornerRadius(10)

            Button(action: {
                UIPasteboard.general.string = textToCopy
            }) {
                Text(&quot;Copy Text&quot;)
                    .padding()
                    .background(Color.blue)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }

            Divider()

            Text(&quot;Pasted Text:&quot;)
            Text(pastedText)
                .padding()
                .background(Color.gray.opacity(0.2))
                .cornerRadius(10)

            Button(action: {
                if let text = UIPasteboard.general.string {
                    pastedText = text
                } else {
                    pastedText = &quot;No text found in clipboard&quot;
                }
            }) {
                Text(&quot;Paste Text&quot;)
                    .padding()
                    .background(Color.green)
                    .foregroundColor(.white)
                    .cornerRadius(10)
            }
        }
        .padding()
    }
}
</code></pre>
<p>In this example:</p>
<ol>
<li>We define two <code class="" data-line="">@State</code> variables <code class="" data-line="">textToCopy</code> and <code class="" data-line="">pastedText</code>.</li>
<li>The &#8220;Copy Text&#8221; button copies <code class="" data-line="">textToCopy</code> to the clipboard.</li>
<li>The &#8220;Paste Text&#8221; button retrieves and displays text from the clipboard in the <code class="" data-line="">pastedText</code> variable.</li>
</ol>
<h2>Conclusion</h2>
<p>Using the clipboard in SwiftUI is straightforward and enhances the interactivity of your app. By understanding how to copy and paste text, you can create more user-friendly interfaces.</p>
<p>The post <a href="https://appmakers.dev/clipboard-copy-and-paste-in-swiftui/">Clipboard &#8211; Copy and Paste in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Gradients in SwiftUI &#8211; Linear, Radial, Angular</title>
		<link>https://appmakers.dev/gradients-in-swiftui-linear-radial-angular/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Tue, 28 May 2024 12:53:45 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Drawing and Animation]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=551</guid>

					<description><![CDATA[<p>Gradients are a powerful tool in SwiftUI that allow you to create visually appealing backgrounds and effects. SwiftUI supports several types of gradients, including linear, radial, and angular gradients. This tutorial will guide you through the basics of using gradients in SwiftUI, with unique and interesting examples that are simple to understand for developers of&#8230;</p>
<p>The post <a href="https://appmakers.dev/gradients-in-swiftui-linear-radial-angular/">Gradients in SwiftUI &#8211; Linear, Radial, Angular</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Gradients are a powerful tool in SwiftUI that allow you to create visually appealing backgrounds and effects. SwiftUI supports several types of gradients, including linear, radial, and angular gradients. This tutorial will guide you through the basics of using gradients in SwiftUI, with unique and interesting examples that are simple to understand for developers of all levels.</p>
<h2>Introduction to Gradients in SwiftUI</h2>
<p>SwiftUI provides built-in support for creating gradients using the <code class="" data-line="">LinearGradient</code>, <code class="" data-line="">RadialGradient</code>, and <code class="" data-line="">AngularGradient</code> views. These gradients can be used to fill shapes, backgrounds, and more.</p>
<h3>Linear Gradient</h3>
<p>A linear gradient creates a color transition along a straight line. You can define the start and end points, as well as the colors to transition between.</p>
<h4>Example: Creating a Linear Gradient</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct LinearGradientView: View {
    var body: some View {
        Rectangle()
            .fill(
                LinearGradient(
                    gradient: Gradient(colors: [Color.red, Color.blue]),
                    startPoint: .topLeading,
                    endPoint: .bottomTrailing
                )
            )
            .frame(width: 200, height: 200)
    }
}
</code></pre>
<p>In this example, we create a <code class="" data-line="">Rectangle</code> filled with a linear gradient that transitions from red to blue, starting from the top leading corner to the bottom trailing corner.</p>
<h3>Radial Gradient</h3>
<p>A radial gradient creates a color transition radiating outward from a center point.</p>
<h4>Example: Creating a Radial Gradient</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct RadialGradientView: View {
    var body: some View {
        Circle()
            .fill(
                RadialGradient(
                    gradient: Gradient(colors: [Color.yellow, Color.orange]),
                    center: .center,
                    startRadius: 20,
                    endRadius: 100
                )
            )
            .frame(width: 200, height: 200)
    }
}</code></pre>
<p>In this example, we create a <code class="" data-line="">Circle</code> filled with a radial gradient that transitions from yellow at the center to orange at the edges.</p>
<h3>Angular Gradient</h3>
<p>An angular gradient creates a color transition around a circle, sweeping from one color to another.</p>
<h4>Example: Creating an Angular Gradient</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct AngularGradientView: View {
    var body: some View {
        Circle()
            .fill(
                AngularGradient(
                    gradient: Gradient(colors: [Color.purple, Color.pink, Color.purple]),
                    center: .center
                )
            )
            .frame(width: 200, height: 200)
    }
}</code></pre>
<p>In this example, we create a <code class="" data-line="">Circle</code> filled with an angular gradient that transitions from purple to pink and back to purple around the center.</p>
<h3>Using EllipticalGradient with Shapes</h3>
<p>Elliptical gradients can be applied to various shapes, not just ellipses. You can use them with rectangles, circles, and custom shapes to create unique visual effects.</p>
<h4>Example: Applying Elliptical Gradient to a Rectangle</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct EllipticalGradientRectangleView: View {
    var body: some View {
        Rectangle()
            .fill(
                EllipticalGradient(
                    gradient: Gradient(colors: [.green, .yellow]),
                    center: .center,
                    startRadiusFraction: 0.2,
                    endRadiusFraction: 0.8
                )
            )
            .frame(width: 300, height: 200)
    }
}
</code></pre>
<h3>Combining Gradients</h3>
<p>You can combine different gradients to create more complex and interesting effects.</p>
<h4>Example: Combining Linear and Radial Gradients</h4>
<pre><code class="language-swift" data-line="">struct CombinedGradientView: View {
    var body: some View {
        ZStack {
            Rectangle()
                .fill(
                    LinearGradient(
                        gradient: Gradient(colors: [Color.blue.opacity(0.5), Color.green.opacity(0.5)]),
                        startPoint: .top,
                        endPoint: .bottom
                    )
                )
                .frame(width: 300, height: 300)
            
            Circle()
                .fill(
                    RadialGradient(
                        gradient: Gradient(colors: [Color.white.opacity(0.5), Color.clear]),
                        center: .center,
                        startRadius: 50,
                        endRadius: 150
                    )
                )
                .frame(width: 300, height: 300)
        }
    }
}</code></pre>
<p>In this example, we create a <code class="" data-line="">Rectangle</code> with a linear gradient background and overlay a <code class="" data-line="">Circle</code> with a radial gradient to create a more complex visual effect.</p>
<h2>Conclusion</h2>
<p>Gradients are a versatile tool in SwiftUI that can enhance the visual appeal of your app. By understanding how to use <code class="" data-line="">LinearGradient</code>, <code class="" data-line="">RadialGradient</code>, and <code class="" data-line="">AngularGradient</code>, you can create stunning effects and backgrounds.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/gradients-in-swiftui-linear-radial-angular/">Gradients in SwiftUI &#8211; Linear, Radial, Angular</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Gestures in SwiftUI: Tap, Long Tap, Drag, Rotation</title>
		<link>https://appmakers.dev/gestures-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Sat, 25 May 2024 09:35:28 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<category><![CDATA[SwiftUI User Interaction]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=545</guid>

					<description><![CDATA[<p>Gestures play a vital role in creating interactive and intuitive user interfaces. SwiftUI offers a variety of gesture recognizers that allow you to add touch and motion-based interactions to your apps easily. This tutorial will guide you through the basics of using gestures in SwiftUI with unique and interesting examples suitable for developers of all&#8230;</p>
<p>The post <a href="https://appmakers.dev/gestures-swiftui/">Gestures in SwiftUI: Tap, Long Tap, Drag, Rotation</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Gestures play a vital role in creating interactive and intuitive user interfaces. SwiftUI offers a variety of gesture recognizers that allow you to add touch and motion-based interactions to your apps easily. This tutorial will guide you through the basics of using gestures in SwiftUI with unique and interesting examples suitable for developers of all levels.</p>
<h2>Introduction to Gestures in SwiftUI</h2>
<p>SwiftUI provides several built-in gestures such as tap, drag, long press, and rotation. You can attach these gestures to any view using the <code class="" data-line="">.gesture</code> modifier. Let&#8217;s explore each of these gestures with practical examples.</p>
<h3>Tap Gesture</h3>
<p>The tap gesture is one of the simplest and most commonly used gestures. It detects a single or multiple taps on a view.</p>
<h4>Example: Using Tap Gesture</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct TapGestureView: View {
    @State private var message = &quot;Tap on the circle&quot;

    var body: some View {
        VStack {
            Circle()
                .fill(Color.blue)
                .frame(width: 100, height: 100)
                .onTapGesture {
                    message = &quot;Circle tapped!&quot;
                }
            Text(message)
                .padding()
        }
    }
}
</code></pre>
<p>In this example, a <code class="" data-line="">Circle</code> view changes the message displayed in the <code class="" data-line="">Text</code> view when tapped.</p>
<h3>Long Press Gesture</h3>
<p>The long press gesture recognizes when a user presses and holds on a view for a specified duration.</p>
<h4>Example: Using Long Press Gesture</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct LongPressGestureView: View {
    @State private var isPressed = false

    var body: some View {
        Circle()
            .fill(isPressed ? Color.red : Color.green)
            .frame(width: 100, height: 100)
            .onLongPressGesture {
                isPressed.toggle()
            }
    }
}
</code></pre>
<p>In this example, the color of the <code class="" data-line="">Circle</code> view toggles between red and green when long pressed.</p>
<h3>Drag Gesture</h3>
<p>The drag gesture allows users to drag views across the screen.</p>
<h4>Example: Using Drag Gesture</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct DragGestureView: View {
    @State private var offset = CGSize.zero
    @State private var startLocation = CGSize.zero

    var body: some View {
        Circle()
            .fill(Color.purple)
            .frame(width: 100, height: 100)
            .offset(x: offset.width + startLocation.width, y: offset.height + startLocation.height)
            .gesture(
                DragGesture()
                    .onChanged { gesture in
                        offset = CGSize(width: gesture.translation.width + startLocation.width,
                                        height: gesture.translation.height + startLocation.height)
                    }
                    .onEnded { gesture in
                        startLocation = CGSize(width: offset.width, height: offset.height)
                        offset = .zero
                    }
            )
    }
}
</code></pre>
<p>In this example, a <code class="" data-line="">Circle</code> view can be dragged around the screen.</p>
<h5>Explanation</h5>
<ol>
<li><strong>State Variables</strong>: We use <code class="" data-line="">offset</code> to track the current drag offset and <code class="" data-line="">startLocation</code> to remember the view&#8217;s position after each drag.</li>
<li><strong>onChanged</strong>: During the drag, we update <code class="" data-line="">offset</code> by adding the current gesture translation to the start location.</li>
<li><strong>onEnded</strong>: When the drag ends, we update <code class="" data-line="">startLocation</code> to the new position and reset <code class="" data-line="">offset</code> to zero for the next drag.</li>
</ol>
<h3>Rotation Gesture</h3>
<p>The rotation gesture detects rotation interactions and can be used to rotate views.</p>
<h4>Example: Using Rotation Gesture</h4>
<pre><code class="language-swift" data-line="">import SwiftUI

struct RotationGestureView: View {
    @State private var rotation: Angle = .zero
    @State private var lastRotation: Angle = .zero

    var body: some View {
        Rectangle()
            .fill(Color.orange)
            .frame(width: 200, height: 200)
            .rotationEffect(rotation + lastRotation)
            .gesture(
                RotationGesture()
                    .onChanged { angle in
                        rotation = angle
                    }
                    .onEnded { angle in
                        lastRotation += rotation
                        rotation = .zero
                    }
            )
    }
}</code></pre>
<h5>Explanation</h5>
<ol>
<li><strong>State Variables</strong>: We use <code class="" data-line="">rotation</code> to track the current rotation during the gesture and <code class="" data-line="">lastRotation</code> to remember the accumulated rotation after each gesture.</li>
<li><strong>onChanged</strong>: During the rotation, we update <code class="" data-line="">rotation</code> to the current gesture&#8217;s angle.</li>
<li><strong>onEnded</strong>: When the rotation ends, we add the current rotation to <code class="" data-line="">lastRotation</code> and reset <code class="" data-line="">rotation</code> to zero for the next gesture.</li>
</ol>
<h3>Combining Gestures</h3>
<p>SwiftUI allows you to combine multiple gestures on a single view using the <code class="" data-line="">.simultaneousGesture</code> modifier.</p>
<h4>Example: Combining Tap and Long Press Gestures</h4>
<pre><code class="language-swift" data-line="">struct CombinedGestureView: View {
    @State private var message = &quot;Tap or Long Press&quot;

    var body: some View {
        VStack {
            Circle()
                .fill(Color.blue)
                .frame(width: 100, height: 100)
                .onTapGesture {
                    message = &quot;Circle tapped!&quot;
                }
                .simultaneousGesture(
                    LongPressGesture()
                        .onEnded { _ in
                            message = &quot;Circle long pressed!&quot;
                        }
                )
            Text(message)
                .padding()
        }
    }
}</code></pre>
<h5>Explanation</h5>
<ol>
<li><strong>State Variable</strong>: We use a <code class="" data-line="">@State</code> variable <code class="" data-line="">message</code> to display the current gesture action.</li>
<li><strong>Circle View</strong>: We create a <code class="" data-line="">Circle</code> view with a blue fill, setting its frame to 100&#215;100 points.</li>
<li><strong>Tap Gesture</strong>: We use <code class="" data-line="">.onTapGesture</code> to detect tap gestures on the <code class="" data-line="">Circle</code> view. When the <code class="" data-line="">Circle</code> is tapped, it updates the <code class="" data-line="">message</code> to &#8220;Circle tapped!&#8221;.</li>
<li><strong>Long Press Gesture</strong>: We use <code class="" data-line="">.simultaneousGesture</code> to combine a <code class="" data-line="">LongPressGesture</code> with the tap gesture. When the <code class="" data-line="">Circle</code> is long-pressed, it updates the <code class="" data-line="">message</code> to &#8220;Circle long pressed!&#8221;.</li>
<li><strong>Text View</strong>: We display the <code class="" data-line="">message</code> in a <code class="" data-line="">Text</code> view below the <code class="" data-line="">Circle</code>, which updates based on the detected gesture.</li>
</ol>
<h5>How It Works</h5>
<ul>
<li><strong>Tap Gesture</strong>: When you tap on the <code class="" data-line="">Circle</code>, the <code class="" data-line="">onTapGesture</code> modifier is triggered, updating the <code class="" data-line="">message</code> to &#8220;Circle tapped!&#8221;.</li>
<li><strong>Long Press Gesture</strong>: When you long press on the <code class="" data-line="">Circle</code>, the <code class="" data-line="">onEnded</code> closure of the <code class="" data-line="">LongPressGesture</code> is triggered, updating the <code class="" data-line="">message</code> to &#8220;Circle long pressed!&#8221;.</li>
</ul>
<p>In this example, the <code class="" data-line="">Circle</code> view can detect both tap and long press gestures, updating the message accordingly.</p>
<h2>Conclusion</h2>
<p>SwiftUI gestures provide a powerful way to create interactive and responsive user interfaces. By understanding and using these gestures, you can enhance the user experience in your apps.</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/gestures-swiftui/">Gestures in SwiftUI: Tap, Long Tap, Drag, Rotation</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>View Groupings in SwiftUI: Group, Form, ControlGroup</title>
		<link>https://appmakers.dev/view-groupings-in-swiftui-group-form-controlgroup/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Fri, 24 May 2024 12:23:59 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Layout, Spacing and Layering]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=540</guid>

					<description><![CDATA[<p>SwiftUI provides powerful tools to group and organize views logically, making your user interfaces clean, maintainable, and easy to understand. In this tutorial, we&#8217;ll explore three essential view groupings: Group, Form, and ControlGroup. We&#8217;ll cover their uses and provide unique examples to help developers of all levels understand and implement these groupings effectively. Group Group&#8230;</p>
<p>The post <a href="https://appmakers.dev/view-groupings-in-swiftui-group-form-controlgroup/">View Groupings in SwiftUI: Group, Form, ControlGroup</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI provides powerful tools to group and organize views logically, making your user interfaces clean, maintainable, and easy to understand. In this tutorial, we&#8217;ll explore three essential view groupings: <code class="" data-line="">Group</code>, <code class="" data-line="">Form</code>, and <code class="" data-line="">ControlGroup</code>. We&#8217;ll cover their uses and provide unique examples to help developers of all levels understand and implement these groupings effectively.</p>
<h2>Group</h2>
<p><code class="" data-line="">Group</code> is a container that groups multiple views together without affecting their layout. It&#8217;s useful for applying modifiers to multiple views simultaneously or organizing code.</p>
<h3>Example: Using Group to Apply Modifiers</h3>
<pre><code class="language-swift" data-line="">import SwiftUI

struct GroupExampleView: View {
    var body: some View {
        VStack {
            Group {
                Text(&quot;Hello, World!&quot;)
                Text(&quot;Welcome to SwiftUI&quot;)
            }
            .font(.headline)
            .foregroundColor(.blue)
            
            Group {
                Image(systemName: &quot;star.fill&quot;)
                Image(systemName: &quot;heart.fill&quot;)
            }
            .foregroundColor(.red)
            .font(.largeTitle)
        }
    }
}
</code></pre>
<p>In this example, we use Group to apply the same modifiers to multiple text and image views. This keeps the code clean and avoids repetition.</p>
<h2>Form</h2>
<p><code class="" data-line="">Form</code> is a container used to arrange controls and text fields in a way that is suitable for data entry. It is typically used for creating forms and settings screens.</p>
<h3>Example: Creating a Simple Form</h3>
<pre><code class="language-swift" data-line="">import SwiftUI

struct SimpleFormView: View {
    @State private var username: String = &quot;&quot;
    @State private var password: String = &quot;&quot;

    var body: some View {
        Form {
            Section(header: Text(&quot;User Information&quot;)) {
                TextField(&quot;Username&quot;, text: $username)
                SecureField(&quot;Password&quot;, text: $password)
            }
            
            Section(header: Text(&quot;Actions&quot;)) {
                Button(action: {
                    print(&quot;Login tapped&quot;)
                }) {
                    Text(&quot;Login&quot;)
                }
            }
        }
    }
}
</code></pre>
<p>This example demonstrates how to create a simple form with text fields and a button. The <code class="" data-line="">Form</code> automatically arranges the elements to look good on all devices.</p>
<h2>ControlGroup</h2>
<p><code class="" data-line="">ControlGroup</code> is a container that visually groups related controls together. It&#8217;s useful for organizing buttons and other interactive elements in a logical and visually appealing way.</p>
<h3>Example: Organizing Buttons with ControlGroup</h3>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ControlGroupExampleView: View {
    var body: some View {
        VStack {
            Text(&quot;Choose an action:&quot;)
                .font(.headline)
                .padding()
            
            ControlGroup {
                Button(action: {
                    print(&quot;Add tapped&quot;)
                }) {
                    Label(&quot;Add&quot;, systemImage: &quot;plus&quot;)
                }
                
                Button(action: {
                    print(&quot;Edit tapped&quot;)
                }) {
                    Label(&quot;Edit&quot;, systemImage: &quot;pencil&quot;)
                }
                
                Button(action: {
                    print(&quot;Delete tapped&quot;)
                }) {
                    Label(&quot;Delete&quot;, systemImage: &quot;trash&quot;)
                }
            }
            .controlGroupStyle(.navigation)
            .padding()
        }
    }
}</code></pre>
<p>In this example, <code class="" data-line="">ControlGroup</code> is used to organize buttons with labels and icons. The <code class="" data-line="">controlGroupStyle</code> modifier is used to change the appearance of the group.</p>
<h2>Conclusion</h2>
<p>SwiftUI&#8217;s <code class="" data-line="">Group</code>, <code class="" data-line="">Form</code>, and <code class="" data-line="">ControlGroup</code> views are essential tools for organizing your UI elements logically and efficiently. By using these containers, you can create clean, maintainable, and user-friendly interfaces.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/view-groupings-in-swiftui-group-form-controlgroup/">View Groupings in SwiftUI: Group, Form, ControlGroup</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>AsyncImage in SwiftUI</title>
		<link>https://appmakers.dev/asyncimage-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Thu, 23 May 2024 12:52:48 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Drawing and Animation]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<category><![CDATA[SwiftUI Views]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=536</guid>

					<description><![CDATA[<p>SwiftUI&#8217;s AsyncImage view simplifies the process of loading and displaying remote images asynchronously. It provides built-in support for placeholders and error handling, making it an essential tool for modern app development. This tutorial will guide you through the basics and demonstrate unique examples that cater to developers of all levels. Introduction to AsyncImage AsyncImage is&#8230;</p>
<p>The post <a href="https://appmakers.dev/asyncimage-in-swiftui/">AsyncImage in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI&#8217;s <code class="" data-line="">AsyncImage</code> view simplifies the process of loading and displaying remote images asynchronously. It provides built-in support for placeholders and error handling, making it an essential tool for modern app development. This tutorial will guide you through the basics and demonstrate unique examples that cater to developers of all levels.</p>
<h3>Introduction to AsyncImage</h3>
<p><code class="" data-line="">AsyncImage</code> is a view that asynchronously loads and displays an image from a specified URL. You can easily add a placeholder, handle errors, and manipulate the loaded image.</p>
<h3>Basic Usage of AsyncImage</h3>
<p>Let&#8217;s start with a basic example of loading an image from a URL and displaying it in a SwiftUI view.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct BasicAsyncImageView: View {
    let imageUrl = URL(string: &quot;https://picsum.photos/200&quot;)

    var body: some View {
        AsyncImage(url: imageUrl)
            .frame(width: 200, height: 200)
    }
}</code></pre>
<p>In this example, we load an image from a URL and display it within a 200&#215;200 frame. Until the image loads, SwiftUI displays a default placeholder.</p>
<h3>Customizing the Placeholder</h3>
<p>You can customize the placeholder to enhance the user experience while the image is loading.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct PlaceholderAsyncImageView: View {
    let imageUrl = URL(string: &quot;https://picsum.photos/200&quot;)

    var body: some View {
        AsyncImage(url: imageUrl) { image in
            image
                .resizable()
                .aspectRatio(contentMode: .fit)
        } placeholder: {
            ProgressView(&quot;Loading...&quot;)
                .frame(width: 200, height: 200)
        }
    }
}
</code></pre>
<p>Here, we use <code class="" data-line="">ProgressView</code> as a custom placeholder, which is displayed until the image is fully loaded.</p>
<h3>Handling Errors</h3>
<p>It&#8217;s crucial to handle errors gracefully, providing a fallback UI when the image fails to load.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ErrorHandlingAsyncImageView: View {
    let imageUrl = URL(string: &quot;https://picsum.photos/200&quot;)

    var body: some View {
        AsyncImage(url: imageUrl) { phase in
            switch phase {
            case .empty:
                ProgressView(&quot;Loading...&quot;)
                    .frame(width: 200, height: 200)
            case .success(let image):
                image
                    .resizable()
                    .aspectRatio(contentMode: .fit)
            case .failure:
                Image(systemName: &quot;exclamationmark.triangle&quot;)
                    .resizable()
                    .frame(width: 50, height: 50)
                    .foregroundColor(.red)
            @unknown default:
                EmptyView()
            }
        }
        .frame(width: 200, height: 200)
    }
}</code></pre>
<p>In this example, we handle different loading phases using a switch statement. If the image fails to load, we display a system symbol as an error indicator.</p>
<h3>Advanced Example: Image Grid</h3>
<p>Let&#8217;s create an advanced example where we display a grid of asynchronously loaded images.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ImageGridAsyncView: View {
    let urls = [
        URL(string: &quot;https://picsum.photos/200/300&quot;),
        URL(string: &quot;https://picsum.photos/200&quot;),
        URL(string: &quot;https://picsum.photos/300&quot;),
        URL(string: &quot;https://picsum.photos/400&quot;)
    ]

    var body: some View {
        let columns = [
            GridItem(.flexible()),
            GridItem(.flexible())
        ]
        
        ScrollView {
            LazyVGrid(columns: columns, spacing: 20) {
                ForEach(urls, id: \.self) { url in
                    AsyncImage(url: url) { phase in
                        switch phase {
                        case .empty:
                            ProgressView()
                                .frame(width: 100, height: 100)
                        case .success(let image):
                            image
                                .resizable()
                                .aspectRatio(contentMode: .fill)
                                .frame(width: 100, height: 100)
                                .clipped()
                        case .failure:
                            Image(systemName: &quot;exclamationmark.triangle&quot;)
                                .resizable()
                                .frame(width: 50, height: 50)
                                .foregroundColor(.red)
                        @unknown default:
                            EmptyView()
                        }
                    }
                }
            }
            .padding()
        }
    }
}</code></pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/asyncimage-in-swiftui/">AsyncImage in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Image in SwiftUI</title>
		<link>https://appmakers.dev/image-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Tue, 21 May 2024 12:21:58 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Drawing and Animation]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<category><![CDATA[SwiftUI Views]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=531</guid>

					<description><![CDATA[<p>SwiftUI provides an easy way for adding and manipulating images in your apps. This tutorial will guide you through the basics of using images in SwiftUI, with unique and interesting examples that cater to developers of all levels. Introduction to Image in SwiftUI The Image view in SwiftUI displays an image and provides various initializers&#8230;</p>
<p>The post <a href="https://appmakers.dev/image-in-swiftui/">Image in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI provides an easy way for adding and manipulating images in your apps. This tutorial will guide you through the basics of using images in SwiftUI, with unique and interesting examples that cater to developers of all levels.</p>
<h2>Introduction to Image in SwiftUI</h2>
<p>The <code class="" data-line="">Image</code> view in SwiftUI displays an image and provides various initializers and modifiers to customize its appearance. You can create images from different sources, such as asset catalogs, <code class="" data-line="">UIImage</code> or <code class="" data-line="">NSImage</code> instances, and SF Symbols.</p>
<h3>Creating a Basic Image</h3>
<p>Let&#8217;s start with a simple example of displaying an image from the app’s asset library.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ContentView: View {
    var body: some View {
        Image(&quot;exampleImage&quot;) // Replace &quot;exampleImage&quot; with your image name
            .resizable()
            .aspectRatio(contentMode: .fit)
            .padding()
    }
}
</code></pre>
<p>In this example, the image is loaded from the asset catalog, made resizable, and its aspect ratio is maintained to fit within its container.</p>
<h2>Customizing Image Views</h2>
<p>SwiftUI provides several modifiers to customize how images are displayed. Here are some useful modifiers and how to use them:</p>
<h3>Resizing and Scaling Images</h3>
<p>You can resize and scale images to fit or fill a given space while maintaining their aspect ratio.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ResizableImageView: View {
    var body: some View {
        VStack {
            Image(&quot;exampleImage&quot;)
                .resizable()
                .scaledToFit()
                .frame(width: 200, height: 200)
                .border(Color.green, width: 1)
            
            Image(&quot;exampleImage&quot;)
                .resizable()
                .scaledToFill()
                .frame(width: 300, height: 200)
                .clipped()
                .border(Color.gray, width: 10)
        }
    }
}
</code></pre>
<h3>Applying Shapes and Borders</h3>
<p>You can apply various shapes and borders to your images to make them more visually appealing.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ShapedImageView: View {
    var body: some View {
        VStack {
            Image(&quot;exampleImage&quot;)
                .resizable()
                .clipShape(Circle())
                .overlay(Circle().stroke(Color.white, lineWidth: 4))
                .shadow(radius: 10)
                .padding()

            Image(&quot;exampleImage&quot;)
                .resizable()
                .clipShape(RoundedRectangle(cornerRadius: 25))
                .overlay(RoundedRectangle(cornerRadius: 25).stroke(Color.white, lineWidth: 4))
                .shadow(radius: 10)
                .padding()
        }
    }
}
</code></pre>
<h3>Applying Color Adjustments to Image in SwiftUI</h3>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ColorAdjustmentImageView: View {
    var body: some View {
        VStack {
            Image(&quot;exampleImage&quot;)
                .resizable()
                .scaledToFit()
                .brightness(0.2) // Increases the brightness of the image
                .contrast(1.5) // Increases the contrast of the image
                .saturation(1.2) // Increases the saturation of the image
                .frame(width: 300, height: 200)
                .padding()
        }
    }
}
</code></pre>
<h3>Applying Blend Mode</h3>
<p>The <code class="" data-line="">blendMode</code> modifier allows you to apply different blending effects to images, combining them with their background or other views.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct BlendModeImageView: View {
    var body: some View {
        VStack {
            Image(&quot;exampleImage&quot;)
                .resizable()
                .scaledToFit()
                .blendMode(.multiply) // Applies multiply blend mode to the image
                .frame(width: 300, height: 200)
                .background(Color.yellow) // Background color to blend with the image
                .padding()
        }
    }
}
</code></pre>
<h3>Rotating and Scaling Images</h3>
<p>You can use the <code class="" data-line="">rotationEffect</code> and <code class="" data-line="">scaleEffect</code> modifiers to rotate and scale images in SwiftUI.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct RotateAndScaleImageView: View {
    var body: some View {
        VStack {
            Image(&quot;exampleImage&quot;)
                .resizable()
                .scaledToFit()
                .rotationEffect(.degrees(45)) // Rotates the image by 45 degrees
                .scaleEffect(1.5) // Scales the image by 1.5 times
                .frame(width: 300, height: 200)
                .padding()
        }
    }
}
</code></pre>
<h3>Using SF Symbols</h3>
<p>SF Symbols are a set of over 2,400 configurable symbols that you can use in your SwiftUI apps. Here&#8217;s how to use them:</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct SFSymbolsView: View {
    var body: some View {
        VStack {
            Image(systemName: &quot;star.fill&quot;)
                .font(.largeTitle)
                .foregroundColor(.yellow)
            
            Image(systemName: &quot;heart.fill&quot;)
                .font(.system(size: 50))
                .foregroundColor(.red)
        }
    }
}
</code></pre>
<h3>Creating a Custom Image with Drawing Instructions</h3>
<p>SwiftUI also allows you to create custom images using drawing instructions. Here’s a simple example:</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md">
<pre><code class="language-swift" data-line="">import SwiftUI

struct CustomDrawingImageView: View {
    var body: some View {
        Image(uiImage: drawCustomImage())
            .resizable()
            .scaledToFit()
            .frame(width: 200, height: 200)
    }
    
    func drawCustomImage() -&gt; UIImage {
        let renderer = UIGraphicsImageRenderer(size: CGSize(width: 200, height: 200))
        return renderer.image { context in
            let cgContext = context.cgContext
            cgContext.setFillColor(UIColor.blue.cgColor)
            cgContext.fill(CGRect(x: 0, y: 0, width: 200, height: 200))
            cgContext.setFillColor(UIColor.white.cgColor)
            cgContext.setStrokeColor(UIColor.red.cgColor)
            cgContext.setLineWidth(10)
            cgContext.addEllipse(in: CGRect(x: 50, y: 50, width: 100, height: 100))
            cgContext.drawPath(using: .fillStroke)
        }
    }
}
</code></pre>
</div>
</div>
<div>
<h2>Conclusion</h2>
<p>SwiftUI’s <code class="" data-line="">Image</code> view is a versatile and powerful tool for displaying and customizing images in your apps. By using various initializers and modifiers, you can create a wide range of image views that are responsive, visually appealing, and accessible.</p>
</div>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center"></div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/image-in-swiftui/">Image in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GeometryReader in SwiftUI</title>
		<link>https://appmakers.dev/geometryreader-in-swiftui/</link>
		
		<dc:creator><![CDATA[AppMakers]]></dc:creator>
		<pubDate>Sat, 18 May 2024 10:35:28 +0000</pubDate>
				<category><![CDATA[Export Locked]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[SwiftUI Layout, Spacing and Layering]]></category>
		<category><![CDATA[SwiftUI Tutorials]]></category>
		<guid isPermaLink="false">https://uiexamples.com/?p=527</guid>

					<description><![CDATA[<p>SwiftUI provides a flexible and powerful way to build user interfaces across all Apple platforms. GeometryReader allows you to read and manipulate the size and position of views dynamically. This tutorial will help you to use GeometryReader effectively. What is GeometryReader? GeometryReader is a container view that defines its content as a function of its&#8230;</p>
<p>The post <a href="https://appmakers.dev/geometryreader-in-swiftui/">GeometryReader in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SwiftUI provides a flexible and powerful way to build user interfaces across all Apple platforms. GeometryReader allows you to read and manipulate the size and position of views dynamically. This tutorial will help you to use GeometryReader effectively.</p>
<h3>What is GeometryReader?</h3>
<p><code class="" data-line="">GeometryReader</code> is a container view that defines its content as a function of its own size and coordinate space. This allows you to create adaptive layouts that respond to changes in view size and position.</p>
<h3>Simple Example of GeometryReader</h3>
<p>Let&#8217;s start with a basic example where we use <code class="" data-line="">GeometryReader</code> to create a view that changes its background color based on its size.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct GeometryReaderExample: View {
    var body: some View {
        GeometryReader { geometry in
            VStack {
                Text(&quot;Width: \(geometry.size.width)&quot;)
                Text(&quot;Height: \(geometry.size.height)&quot;)
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            .background(geometry.size.width &gt; 200 ? Color.blue : Color.red)
        }
        .frame(height: 200)
    }
}
</code></pre>
<p>In this example, the background color of the <code class="" data-line="">VStack</code> changes based on the width of the <code class="" data-line="">GeometryReader</code>. If the width is greater than 200 points, the background color will be blue; otherwise, it will be red.</p>
<h3>Using GeometryReader for Complex Layouts</h3>
<p>Here is a more complex example that demonstrates how <code class="" data-line="">GeometryReader</code> can be used to create a responsive grid layout.</p>
<pre><code class="language-swift" data-line="">import SwiftUI

struct ResponsiveGridExample: View {
    var body: some View {
        GeometryReader { geometry in
            let width = geometry.size.width
            let columns = Int(width / 100)
            let itemSize = width / CGFloat(columns)
            
            VStack {
                ForEach(0..&lt;10) { row in
                    HStack {
                        ForEach(0..&lt;columns, id: \.self) { column in
                            Rectangle()
                                .fill(Color.blue)
                                .frame(width: itemSize, height: itemSize)
                        }
                    }
                }
            }
        }
        .padding()
    }
}

</code></pre>
<h3>Explanation</h3>
<ol>
<li><strong>GeometryReader</strong>: This reads the size of the parent view.</li>
<li><strong>Calculating Columns and Item Size</strong>: We calculate the number of columns and the size of each item based on the width of the parent view.</li>
<li><strong>VStack and HStack</strong>: We use <code class="" data-line="">VStack</code> and <code class="" data-line="">HStack</code> to create rows and columns. The <code class="" data-line="">ForEach</code> loop is used to generate the grid items dynamically.</li>
<li><strong>Dynamic Range Fix</strong>: We use <code class="" data-line="">id: \.self</code> in the <code class="" data-line="">ForEach</code> loop to ensure each item is uniquely identified, which resolves the &#8220;Non-constant range&#8221; error.</li>
</ol>
<p>&nbsp;</p>
<p>The post <a href="https://appmakers.dev/geometryreader-in-swiftui/">GeometryReader in SwiftUI</a> appeared first on <a href="https://appmakers.dev">AppMakers.Dev</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
