mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +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
|
||||
|
||||
final class AppIconImageView: UIImageView
|
||||
extension AppIconImageView
|
||||
{
|
||||
enum Style
|
||||
{
|
||||
case icon
|
||||
case circular
|
||||
}
|
||||
}
|
||||
|
||||
class AppIconImageView: UIImageView
|
||||
{
|
||||
var style: Style = .icon {
|
||||
didSet {
|
||||
self.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
override func awakeFromNib()
|
||||
{
|
||||
super.awakeFromNib()
|
||||
@@ -25,8 +40,16 @@ final class AppIconImageView: UIImageView
|
||||
{
|
||||
super.layoutSubviews()
|
||||
|
||||
// Based off of 60pt icon having 12pt radius.
|
||||
let radius = self.bounds.height / 5
|
||||
self.layer.cornerRadius = radius
|
||||
switch self.style
|
||||
{
|
||||
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