mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Also tints all navigation bar buttons to match source/category tint color. # Conflicts: # AltStore/Browse/BrowseViewController.swift
70 lines
1.3 KiB
Swift
70 lines
1.3 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()
|
|
}
|
|
}
|
|
|
|
init(style: Style)
|
|
{
|
|
self.style = style
|
|
|
|
super.init(image: nil)
|
|
|
|
self.initialize()
|
|
}
|
|
|
|
required init?(coder: NSCoder)
|
|
{
|
|
super.init(coder: coder)
|
|
|
|
self.initialize()
|
|
}
|
|
|
|
private func initialize()
|
|
{
|
|
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
|
|
}
|
|
}
|
|
}
|