<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Context Menu on Mike Gopsill</title>
    <link>https://www.mikegopsill.com/tags/context-menu/</link>
    <description>Recent content in Context Menu on Mike Gopsill</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en</language>
    <lastBuildDate>Sun, 11 May 2025 08:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.mikegopsill.com/tags/context-menu/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Using Context Menu with Previews in SwiftUI</title>
      <link>https://www.mikegopsill.com/posts/swiftui-context-menu-previews/</link>
      <pubDate>Sun, 11 May 2025 08:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-context-menu-previews/</guid>
      <description>&lt;p&gt;SwiftUI’s &lt;code&gt;contextMenu&lt;/code&gt; modifier is a simple API that does a lot for us.&lt;/p&gt;
&lt;p&gt;I wrote about &lt;strong&gt;building context menus in both &lt;a href=&#34;https://www.mikegopsill.com/posts/uikit-context-menus/&#34;&gt;UIKit&lt;/a&gt; and &lt;a href=&#34;https://www.mikegopsill.com/posts/swiftui-context-menus/&#34;&gt;SwiftUI&lt;/a&gt;&lt;/strong&gt; recently. I did not go into detail about support for the &lt;strong&gt;custom previews&lt;/strong&gt; that landed in iOS 16, iPadOS 16 and macOS 13. Let us fill that gap.&lt;/p&gt;
&lt;h2 id=&#34;recap-context-menus-in-swiftui&#34;&gt;Recap: Context menus in SwiftUI&lt;/h2&gt;
&lt;p&gt;A context menu is equivalent of a right-click on touch devices. Using long‑press (or Control‑click on the Mac) on a view reveals a menu of options exactly where the user needs it. In pure SwiftUI we use &lt;code&gt;.contextMenu&lt;/code&gt; to create these menus:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use Context Menus in UIKit</title>
      <link>https://www.mikegopsill.com/posts/uikit-context-menus/</link>
      <pubDate>Fri, 09 May 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/uikit-context-menus/</guid>
      <description>&lt;p&gt;In this post we&amp;rsquo;re going to add context menus to a UIKit &lt;code&gt;UITableView&lt;/code&gt;. The end goal is to have something that looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&#34;Context-menu demo UIKit&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/uikit-context-menus/context-menu-demo-uikit.gif#center&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;why-use-context-menus&#34;&gt;Why Use Context Menus?&lt;/h2&gt;
&lt;p&gt;Context menus are great for keeping things tidy while still offering useful features. They:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep your UI minimal&lt;/li&gt;
&lt;li&gt;Only show options when needed&lt;/li&gt;
&lt;li&gt;Feel natural with the iOS long-press gesture&lt;/li&gt;
&lt;li&gt;Save you adding extra buttons all over the UI – the menu keeps them tucked out of sight until needed.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;what-were-making&#34;&gt;What We’re Making&lt;/h2&gt;
&lt;p&gt;We’ll show a short list of fruit. When we long-press any item we will show a context menu with three options:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use Context Menus in SwiftUI</title>
      <link>https://www.mikegopsill.com/posts/swiftui-context-menus/</link>
      <pubDate>Thu, 08 May 2025 00:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/swiftui-context-menus/</guid>
      <description>&lt;p&gt;The aim for this post to build a very simple &lt;code&gt;List&lt;/code&gt; view. When you long-press a row you will see a classic iOS context menu. It will look a little like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&#34;Context-menu demo&#34; loading=&#34;lazy&#34; src=&#34;https://www.mikegopsill.com/posts/swiftui-context-menus/context-menu-demo.gif#center&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;why-context-menus&#34;&gt;Why Context Menus?&lt;/h2&gt;
&lt;p&gt;Context menus give users an easy way to discover secondary actions &lt;em&gt;right where they’re looking&lt;/em&gt;. They:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep the primary UI clean.&lt;/li&gt;
&lt;li&gt;Surface actions only when they’re relevant.&lt;/li&gt;
&lt;li&gt;Feel familiar thanks to the long-press gesture we already use across iOS.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;what-well-build&#34;&gt;What We’ll Build&lt;/h2&gt;
&lt;p&gt;We’ll create a simple list of fruit. A long-press on any row reveals three actions:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
