2019-05-09 15:29:54 -07:00
|
|
|
//
|
|
|
|
|
// AppIconImageView.swift
|
|
|
|
|
// AltStore
|
|
|
|
|
//
|
|
|
|
|
// Created by Riley Testut on 5/9/19.
|
|
|
|
|
// Copyright © 2019 Riley Testut. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
2023-10-16 18:40:01 -05:00
|
|
|
extension AppIconImageView
|
2019-05-09 15:29:54 -07:00
|
|
|
{
|
2023-10-16 18:40:01 -05:00
|
|
|
enum Style
|
|
|
|
|
{
|
|
|
|
|
case icon
|
|
|
|
|
case circular
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AppIconImageView: UIImageView
|
|
|
|
|
{
|
|
|
|
|
var style: Style = .icon {
|
|
|
|
|
didSet {
|
|
|
|
|
self.setNeedsLayout()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-09 15:29:54 -07:00
|
|
|
override func awakeFromNib()
|
|
|
|
|
{
|
|
|
|
|
super.awakeFromNib()
|
|
|
|
|
|
|
|
|
|
self.contentMode = .scaleAspectFill
|
|
|
|
|
self.clipsToBounds = true
|
2019-07-19 16:42:40 -07:00
|
|
|
self.backgroundColor = .white
|
2023-03-02 16:53:36 -06:00
|
|
|
|
|
|
|
|
self.layer.cornerCurve = .continuous
|
2019-05-09 15:29:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func layoutSubviews()
|
|
|
|
|
{
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
2023-10-16 18:40:01 -05:00
|
|
|
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
|
|
|
|
|
}
|
2019-05-09 15:29:54 -07:00
|
|
|
}
|
|
|
|
|
}
|