<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>presentedWindowStyle &#8211; Wade Tregaskis</title>
	<atom:link href="https://wadetregaskis.com/tags/presentedwindowstyle/feed/" rel="self" type="application/rss+xml" />
	<link>https://wadetregaskis.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Sep 2024 18:03:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://wadetregaskis.com/wp-content/uploads/2016/03/Stitch-512x512-1-256x256.png</url>
	<title>presentedWindowStyle &#8211; Wade Tregaskis</title>
	<link>https://wadetregaskis.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">226351702</site>	<item>
		<title>presentedWindowStyle is not windowStyle</title>
		<link>https://wadetregaskis.com/presentedwindowstyle-is-not-windowstyle/</link>
					<comments>https://wadetregaskis.com/presentedwindowstyle-is-not-windowstyle/#respond</comments>
		
		<dc:creator><![CDATA[]]></dc:creator>
		<pubDate>Mon, 23 Sep 2024 23:12:29 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Feedback Assistant]]></category>
		<category><![CDATA[Happy]]></category>
		<category><![CDATA[presentedWindowStyle]]></category>
		<category><![CDATA[SwiftUI]]></category>
		<category><![CDATA[Undocumented]]></category>
		<category><![CDATA[windowStyle]]></category>
		<guid isPermaLink="false">https://wadetregaskis.com/?p=8460</guid>

					<description><![CDATA[This post is mostly to herald a pretty good Apple bug report response, which as we know is a too-rare event. But it might also help others with this confusing SwiftUI API. What&#8217;s the difference between presentedWindowStyle(_:) and windowStyle(_:)? Well, one does something, the other doesn&#8217;t, basically. I tried using the former, and observed that&#8230; <a class="read-more-link" href="https://wadetregaskis.com/presentedwindowstyle-is-not-windowstyle/" data-wpel-link="internal">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>This post is mostly to herald a pretty good Apple bug report response, which as we know is a too-rare event.  But it might also help others with this confusing SwiftUI API.</p>



<p>What&#8217;s the difference between <code><a href="https://developer.apple.com/documentation/swiftui/view/presentedwindowstyle(_:)" data-wpel-link="external" target="_blank" rel="external noopener">presentedWindowStyle(_:)</a></code> and <code><a href="https://developer.apple.com/documentation/swiftui/scene/windowstyle(_:)" data-wpel-link="external" target="_blank" rel="external noopener">windowStyle(_:)</a></code>?</p>



<p>Well, one does something, the other doesn&#8217;t, basically.</p>



<p>I tried using the former, and observed that it never has any effect.  I filed FB14892608 about it, a month ago.  While the long delay isn&#8217;t great, the response I got today was actually pretty helpful:</p>



<pre class="wp-block-preformatted">We’re sorry you ran into trouble with that API.<br><br>To adjust the style of a window group’s windows, you have a couple of options. If all of the windows in the group should have the same style, then using the windowStyle() scene modifier is what you want:<br><br>struct MyApp: App {<br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>        }<br>        .windowStyle(.hiddenTitleBar)<br>    }<br>}<br><br>If you need to adjust the style on an individual basis using state for that window, there are also some related view modifiers:<br>struct MyApp: App {<br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>                .toolbar(removing: .title)<br>                .toolbarBackgroundVisibility(.hidden, for: .windowToolbar)<br>        }<br>    }<br>}</pre>



<p>A simple apology followed by clear and specific instructions on how to actually achieve what I wanted.  I genuinely applaud Apple &#8211; or perhaps I should more specifically thank the individual(s) within DTS that actually provided this response.  Either way, it was a very pleasant surprise.</p>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-dots"/>



<p>Now, it still leaves unanswered the question of what <code>presentedWindowStyle(_:)</code> is supposed to be for, and in what situations it actually <em>does</em> anything.  So not a perfect reply, per se, but really the proper solution for that is either:</p>



<ol style="list-style-type:upper-alpha" class="wp-block-list">
<li>Fix the API to not have such confusingly similar modifiers.</li>



<li>Improve the documentation to:
<ul class="wp-block-list">
<li>Explicitly point out the other, similarly-named modifier.</li>



<li>Distinguish them.</li>
</ul>
</li>
</ol>



<p>Currently the documentation is just:</p>



<figure class="wp-block-pullquote"><blockquote><p>Sets the style for windows created by this scene.</p><cite><a href="https://developer.apple.com/documentation/swiftui/scene/windowstyle(_:)" data-wpel-link="external" target="_blank" rel="external noopener"><code>windowStyle(_:)</code> documentation</a></cite></blockquote></figure>



<p>Versus:</p>



<figure class="wp-block-pullquote"><blockquote><p>Sets the style for windows created by interacting with this view.</p><cite><a href="https://developer.apple.com/documentation/swiftui/view/presentedwindowstyle(_:)" data-wpel-link="external" target="_blank" rel="external noopener"><code>presentedWindowStyle(_:)</code> documentation</a></cite></blockquote></figure>



<p>The latter might <em>technically</em> convey something important here, in the <em>created by interacting with this view</em> part, but so much in SwiftUI is modifiers stuck haphazardly in weird and arbitrary places, that I&#8217;m been conditioned to ignore the fact that I&#8217;m often applying modifiers to views that don&#8217;t actually affect those views.  And for all I know in SwiftUI parlance views <em>do</em> &#8220;create&#8221; and/or &#8220;interact&#8221; with their parent windows (a <em>lot</em> about SwiftUI is backwards, part of its nature as a declarative API).</p>



<p>Especially if that&#8217;s the first candidate API you stumble across, when searching for a way to style a window, it&#8217;s very easy to presume it&#8217;s the right API.  Why would there be <em>multiple</em> APIs for styling the window; why would you continue searching after finding one?</p>



<p>Similarly, the <code>presentedWindowStyle(_:)</code> variant is the <em>only</em> one that appears in Xcode&#8217;s auto-complete if you try to add the modifier to your main view, which is both where you sometimes <em>have</em> to add window-level modifiers and also just a really easy mistake to make (instead of adding the modifier to the <code><a href="https://developer.apple.com/documentation/swiftui/windowgroup" data-wpel-link="external" target="_blank" rel="external noopener">WindowGroup</a></code>, one indentation level up).</p>



<p>Lastly, it doesn&#8217;t help that I can&#8217;t find <em>any</em> situation in which <code>presentedWindowStyle(_:)</code> has any effect, even knowing it&#8217;s not intended to style the parent window. One might assume it&#8217;s somehow related to sheets or somesuch, but apparently not? Presumably I&#8217;m overlooking some use-case &#8211; or maybe it <em>doesn&#8217;t</em> actually do anything on macOS, only iDevices? I welcome clues or tips.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wadetregaskis.com/presentedwindowstyle-is-not-windowstyle/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">8460</post-id>	</item>
	</channel>
</rss>
