惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
T
Tailwind CSS Blog
博客园_首页
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
J
Java Code Geeks
量子位
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
C
Check Point Blog
V
Visual Studio Blog
H
Help Net Security
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta

alexwlchan’s notes

What is WS11 1DB? Blocking referrers with Caddy How to type a Spanish question mark (¿) on a Mac Non-overlapping type comparisons and Python type checkers Why does t.Setenv panic after t.Parallel? Use Path.glob() and Path.rglob() for typed versions of glob.glob() Curious clocks and colourful eyes Track which templates are used by Jinja2 Archeologists distinguish between “sherds” and “shards” A single command to test all my changed Go packages Disable the new message animations in WhatsApp Finding high-churn folders that bother Backblaze Always-on SSH agent forwarding with my Git pushes Managing the caption of a photo with AppleScript (but not PhotoKit) Goodhart’s and Campbell’s Law are different Notes from The Cornishman No. 176 (Spring 2026) Notes from The Cornishman No. 176 (Spring 2026) GitUp can’t diff text files larger than 8MB Home Testing the width of a page on a mobile device using Playwright Disable AirPods charging notifications Start a Caddy server in a subprocess during a Python session Filter a list of JSON object based on a list of tags HOME_GET_ME_HOME is a Citymapper Shortcuts action The FileExistsError exception exposes a filename attribute The red-lined bubble snail Why can’t Python connect to example.com? Useful type hints for Python How to truncate the middle of long command output AirPlay Receiver can interfere with Flask apps
Drawing an image with Liquid Glass using SwiftUI Previews
2026-03-07 · via alexwlchan’s notes

I used Xcode to create an image with a Liquid Glass effect, then I used the Preview to export it as a standalone file.

Earlier this week Apple announced a “new” Studio Display which is almost the same as the previous Studio Display, only gaining a better camera and Thunderbolt 5.

Jack Wellborn posted an image on Mastodon joking about the lack of new features – one of Apple’s marketing images overlaid with a blue “new” banner in the corner, which is how Apple’s online store used to highlight new products. The Accidental Tech Podcast used a similar image as their artwork and favicon for years, joking about the lack of updates to the Mac Pro.

I wanted to create a similar image with a “new” banner in the style of Liquid Glass, to make fun of the design problems in macOS Tahoe. Initially I tried creating it in Acorn, but I lack the graphical design skills to replicate the effect – I realised it would be easier to create the effect in code.

I opened Xcode on a Mac running macOS Tahoe and created a new Mac app. I added one of Apple’s marketing images to the Asset catalogue, then I modified the default SwiftUI view ContentView:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Image("center_stage_hw_studio_display__f0h1yn012iie_large_2x")
                .imageScale(.small)
                .foregroundStyle(.tint)
                .overlay(alignment: .topTrailing) {
                    Text("NEW")
                        .font(.title)
                        .foregroundColor(.white)
                        .padding()
                        .frame(width:400, height:5)
                        .glassEffect(.clear, in: Rectangle())
                        .offset(x:150,y:-150)
                        .rotationEffect(.degrees(45))
                        .overlay(alignment: .bottom) {
                            Text("NEW")
                                .font(.system(size: 120))
                                .foregroundColor(.white)
                                .rotationEffect(.degrees(45))
                                .offset(x:-25, y:300)
                                .blur(radius: 1.5)
                                .opacity(0.7)
                        }
                }
                .clipped()
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

I ran Xcode with two panes: my source code on the left, my preview on the right. That worked well for iterating the design, because I could tweak the source code and immediately see the effect.

Even with my limited SwiftUI experience, I know this isn’t very good – for example, I have two Text views, because I couldn’t make the first one work. (Specifically, I couldn’t make it work with glassEffect and rotationEffect – the text was rotated within a horizontal glass container.)

I also couldn’t get the banner to be a thin rectangle; I ended up drawing a large rectangle that clips out of the view (clipped()) and overlaps the entire corner. Let’s retcon that as an homage to the way Tahoe’s UI supposedly “gets out of your way”, but actually takes over even more of your screen.

Rubbish as this code is, it does the trick! And I discovered that Xcode has a menu item to export the SwiftUI Preview as an image: Editor > Canvas > Export Preview Screenshot. I was using Xcode 26; I imagine that menu item might move around in different versions.

Here’s what the output looks like:

A photo of a large display with a glassy triangle in the top right-hand corner which has the word 'New' shown in blurry, barely-visible text.

I don’t expect to create more images like this, but it’s cool to know I could use Xcode to mock up UI or Liquid Glass quickly, and export my work as images.