Files
POCloud-iOS/pocloud/View/PillUILabel.swift
2018-06-06 18:39:18 -05:00

46 lines
1.1 KiB
Swift

//
// PillUILabel.swift
// pocloud
//
// Created by Patrick McDonagh on 6/6/18.
// Copyright © 2018 patrickjmcd. All rights reserved.
//
import UIKit
@IBDesignable class PillUILabel : UILabel {
@IBInspectable var verticalPad: CGFloat = 0
@IBInspectable var horizontalPad: CGFloat = 0
func setup() {
layer.cornerRadius = frame.height / 2
clipsToBounds = true
textAlignment = .center
}
override func awakeFromNib() {
super.awakeFromNib()
setup()
}
override func layoutSubviews() {
super.layoutSubviews()
setup()
}
override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
setup()
}
override var intrinsicContentSize: CGSize {
let superSize = super.intrinsicContentSize
let newWidth = superSize.width + superSize.height + (2 * horizontalPad)
let newHeight = superSize.height + (2 * verticalPad)
let newSize = CGSize(width: newWidth, height: newHeight)
return newSize
}
}