14.5 C
Canberra
Saturday, February 14, 2026

iOS 26, utilizing Swift, how can I group a number of Liquid Glass buttons right into a single tablet view?


In iOS 26, how can I group a number of Liquid Glass buttons right into a single tablet view as a substitute of separate buttons that my code at present does.

Word that I want to make use of UIKit, not SwiftUI.

Under code:

import UIKit
import SnapKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        tremendous.viewDidLoad()
        
        let container = UIVisualEffectView()
        
        let impact = UIGlassContainerEffect()
        impact.spacing = 10
        container.impact = impact
        
        let uIStackView = UIStackView()
        uIStackView.axis = .horizontal

        uIStackView.addArrangedSubview(button(systemName: "arrow.uturn.backward"))
        uIStackView.addArrangedSubview(button(systemName: "arrow.trianglehead.2.clockwise.rotate.90"))
        uIStackView.addArrangedSubview(button(systemName: "speaker.wave.3.fill"))
        uIStackView.addArrangedSubview(button(systemName: "star.fill"))
        
        container.contentView.addSubview(uIStackView)
        uIStackView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        view.addSubview(container)
        container.snp.makeConstraints { make in
            make.middle.equalToSuperview()
        }
    }

    func button(systemName : String) -> UIButton {
        let config = UIImage.SymbolConfiguration(pointSize: 14)
        
        let button = UIButton()
        button.setImage(UIImage(systemName: systemName, withConfiguration: config), for: .regular)
        button.configuration = .glass()
        let padding = 15.0
        button.configuration?.contentInsets = NSDirectionalEdgeInsets(prime: padding, main: padding, backside: padding, trailing: padding)
                    
        return button
    }    
}

Offers:

iOS 26, utilizing Swift, how can I group a number of Liquid Glass buttons right into a single tablet view?

As you may see, every button is being rendered as separate as a substitute of a single tablet like view.

This text makes use of glassEffectUnion to realize it in SwiftUI. How can this be achieved in Swift as a substitute of SwiftUI?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles