Skip to content

Instantly share code, notes, and snippets.

@thomsmed
Created October 29, 2021 20:42
Show Gist options
  • Save thomsmed/3da448ed66112f4b9cbaf17b576949c7 to your computer and use it in GitHub Desktop.
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
//
// 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