Created
October 29, 2021 20:42
-
-
Save thomsmed/3da448ed66112f4b9cbaf17b576949c7 to your computer and use it in GitHub Desktop.
Simple circular view where corner radius is controled by the shortes side of the view
This file contains 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
// | |
// CircularView.swift | |
// | |
import Foundation | |
import UIKit | |
class CircularView: UIView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
layer.cornerRadius = CGFloat(min(bounds.width / 2, bounds.height / 2)) | |
layer.masksToBounds = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment