mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
Adds AppIconImageView.style to switch between icon and circular styles
`icon` approximates the rounded corners of an app icon, while `circular` makes the icon a circle.
This commit is contained in:
@@ -8,8 +8,23 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
extension AppIconImageView
|
||||||
|
{
|
||||||
|
enum Style
|
||||||
|
{
|
||||||
|
case icon
|
||||||
|
case circular
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class AppIconImageView: UIImageView
|
class AppIconImageView: UIImageView
|
||||||
{
|
{
|
||||||
|
var style: Style = .icon {
|
||||||
|
didSet {
|
||||||
|
self.setNeedsLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func awakeFromNib()
|
override func awakeFromNib()
|
||||||
{
|
{
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
@@ -25,8 +40,16 @@ class AppIconImageView: UIImageView
|
|||||||
{
|
{
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
// Based off of 60pt icon having 12pt radius.
|
switch self.style
|
||||||
let radius = self.bounds.height / 5
|
{
|
||||||
self.layer.cornerRadius = radius
|
case .icon:
|
||||||
|
// Based off of 60pt icon having 12pt radius.
|
||||||
|
let radius = self.bounds.height / 5
|
||||||
|
self.layer.cornerRadius = radius
|
||||||
|
|
||||||
|
case .circular:
|
||||||
|
let radius = self.bounds.height / 2
|
||||||
|
self.layer.cornerRadius = radius
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user