Files
SideStore/AltStore/Components/AppIconImageView.swift
Riley Testut df43561494 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.
2024-12-26 21:15:29 +05:30

56 lines
1.1 KiB
Swift

//
// AppIconImageView.swift
// AltStore
//
// Created by Riley Testut on 5/9/19.
// Copyright © 2019 Riley Testut. All rights reserved.
//
import UIKit
extension AppIconImageView
{
enum Style
{
case icon
case circular
}
}
class AppIconImageView: UIImageView
{
var style: Style = .icon {
didSet {
self.setNeedsLayout()
}
}
override func awakeFromNib()
{
super.awakeFromNib()
self.contentMode = .scaleAspectFill
self.clipsToBounds = true
self.backgroundColor = .white
self.layer.cornerCurve = .continuous
}
override func layoutSubviews()
{
super.layoutSubviews()
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
}
}
}