Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class CardView: UIButton {
- override func draw(_ rect: CGRect) {
- //activating this function enables the borders, even when I draw a Bezier path in this function the borders doesn't disappear
- }
- }
- import UIKit
- class CardContainerView: UIView {
- // Create Cards
- var cardViews = [CardView](){
- didSet {
- for card in cardViews {
- addSubview(card)
- card.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
- card.layer.borderColor = UIColor.white.cgColor
- card.layer.borderWidth = 0
- }
- }
- }
- private(set) var grid = Grid(layout: Grid.Layout.aspectRatio(3/2))
- /// The centered rect in which the buttons are going to be positioned.
- private var centeredRect: CGRect {
- get {
- return CGRect(x: bounds.size.width * 0.025,
- y: bounds.size.height * 0.025,
- width: bounds.size.width * 0.95,
- height: bounds.size.height * 0.95)
- }
- }
- override func layoutSubviews() {
- super.layoutSubviews()
- grid.cellCount = cardViews.count
- grid.frame = centeredRect
- for i in 0...cardViews.count {
- if let frame = grid[i] {
- cardViews[i].frame = frame
- cardViews[i].layer.cornerRadius = 10
- cardViews[i].layer.borderColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0)
- cardViews[i].layer.borderWidth = 0.0
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment