forked from mamaral/Neon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageContainerView.swift
41 lines (33 loc) · 1.1 KB
/
ImageContainerView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// ImageContainerView.swift
// Neon
//
// Created by Mike on 9/26/15.
// Copyright © 2015 Mike Amaral. All rights reserved.
//
import UIKit
import Neon
class ImageContainerView: UIView {
let imageView : UIImageView = UIImageView()
let label : UILabel = UILabel()
convenience init() {
self.init(frame: CGRect.zero)
self.backgroundColor = UIColor.white
self.layer.cornerRadius = 4.0
self.layer.borderWidth = 1.0
self.layer.borderColor = UIColor(white: 0.68, alpha: 1.0).cgColor
self.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
self.addSubview(imageView)
label.textAlignment = .center
label.textColor = UIColor.black
label.font = UIFont.boldSystemFont(ofSize: 14.0)
self.addSubview(label)
}
override func layoutSubviews() {
super.layoutSubviews()
imageView.anchorAndFillEdge(.top, xPad: 0, yPad: 0, otherSize: self.height * 0.7)
label.alignAndFill(align: .underCentered, relativeTo: imageView, padding: 0)
}
}