This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // UIGlassContainerEffect-Demo | |
| // | |
| // Created by Seb Vidal on 04/11/2025. | |
| // | |
| import UIKit | |
| import MapKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension NSView { | |
| func renderWithCARenderer() -> NSImage? { | |
| let width = Int(frame.width * 2) | |
| let height = Int(frame.height * 2) | |
| frame.origin = CGPoint(x: 0, y: 0) | |
| let descriptor = MTLTextureDescriptor.texture2DDescriptor(pixelFormat: .rgba8Unorm, width: width, height: height, mipmapped: true) | |
| descriptor.usage = [.shaderRead, .shaderWrite, .renderTarget] | |
| let device = MTLCreateSystemDefaultDevice()! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func setupCollectionView() { | |
| let layout = UICollectionViewCompositionalLayout { [unowned self] section, environment in | |
| let spacing: CGFloat = 8 | |
| let numberOfColumns: CGFloat = 5 | |
| let numberOfSpacers: CGFloat = numberOfColumns - 1 | |
| let contentWidth = collectionView.layoutMarginsGuide.layoutFrame.width | |
| let itemWidth = (contentWidth - numberOfSpacers * spacing) / numberOfColumns | |
| let layoutItemSize = NSCollectionLayoutSize(widthDimension: .absolute(itemWidth), heightDimension: .fractionalHeight(1)) |
OlderNewer