Archive for May 25, 2022

Wednesday, May 25, 2022

AttributedString Attribute Scopes

Natalia Panferova:

UIKit and AppKit attribute scopes have many attributes with matching names but different value types. Attributes with types defined in UIKit such as UIColor, UIFont etc. are available on platforms that can import UIKit and attributes with types defined in AppKit such as NSColor, NSFont etc. are available on macOS. AttributeScopes.UIKitAttributes type contains the full list of UIKit attributes and AttributeScopes.AppKitAttributes contains the full list of AppKit attributes.

Foundation can infer the right type of the attribute to use when we assign the value. The following code will assign as foreground color when UIKit is imported and when AppKit is imported.


Note, that when SwiftUI is imported SwiftUI attributes take priority and the resulting attribute value will be that is defined in the SwiftUI framework.


We can even define our own attributes and attribute scopes. This can be useful if we are building a framework or a package or just want to extend AttributedString functionality in our app.

See also: NSAttributedStringBuilder (via Kaya Thomas).


Silencing a Family Member’s Alarm

Tim Hardwick:

If you live in a family household, there’s a good chance that at some stage you’ve been disturbed by someone else’s alarm going off on their iPhone. If their phone is out of your reach and no one else is bothering to turn off the alarm, the disturbance can quickly become irritating, but if your own iPhone or iPad is nearby, there’s a handy trick you can use to silence that alarm without you having to get up.

That’s great, but how are you supposed to discover this if it’s only available via Siri?

The Rise of Canva

Mark Wilson:

As for Canva, where Perkins is CEO and Obrecht is chief operating officer: It’s now one of the most influential design platforms on the planet, with 75 million monthly active users who create, on average, 150 designs every second. The company, which is valued at $40 billion, expects to exceed $1 billion in revenue in 2022.

While many unicorns pivot again and again to find their market, Canva’s proposition today is remarkably similar to that pitch of more than a decade ago. Its easy-to-use, templated design platform allows people to create business cards, birthday invitations, social media ads, sales presentations, coffee mugs, and yearbooks. It works equally well on a phone, tablet, or laptop. Canva is a word processor for our modern visual culture, adjusting anything you see—text, an image, a background, an animation—with a simple tap.


Canva wants to push exporting options even further, by breaking its users out of the most limited format in design: the PDF. Later this year, Canva will begin allowing users to export projects not just as PDFs, but as single-serve websites with unique URLs. So a wedding invite built in Canva could be instantly published to the web, complete with the ability to accept RSVPs. Canva is reimagining stagnant files as interactive, shareable sites, which Perkins believes will be the predominant way designs are shared well into the future.