Lorenzo Fiamingo
Lorenzo Fiamingo

Reputation: 4109

How to replicate UIKit/SwiftUI elements background (like the UITabBar/TabView background)

I would like to replicate the background (including the same blur effect and the thin gray border and their adaptivity) of UITabBar (and similar UIKit/SwiftUI elements) and apply it to another UI element. How can I accomplish that?

I've tried to copy it but when I stack my new view on other different color views the behavior is different (and neither the night mode is supported).

I don't care if the answer will be for UIKit or SwiftUI framework.

Upvotes: 1

Views: 172

Answers (1)

Asperi
Asperi

Reputation: 258285

See UIColor extensions in UIInterface module, like below examples (there are many there):

 * 1. systemBackground
 *    Use this stack for views with standard table views, and designs which have a white
 *    primary background in light mode.
 */
@available(iOS 13.0, *)
open class var systemBackground: UIColor { get }


/* 2. systemGroupedBackground
 *    Use this stack for views with grouped content, such as grouped tables and
 *    platter-based designs. These are like grouped table views, but you may use these
 *    colors in places where a table view wouldn't make sense.
 */
@available(iOS 13.0, *)
open class var systemGroupedBackground: UIColor { get }


/* Fill colors for UI elements.
 * These are meant to be used over the background colors, since their alpha component is less than 1.
 *
 * systemFillColor is appropriate for filling thin and small shapes.
 * Example: The track of a slider.
 */
@available(iOS 13.0, *)
open class var systemFill: UIColor { get }

Upvotes: 1

Related Questions