-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardView.swift
31 lines (25 loc) · 919 Bytes
/
CardView.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
//
// CardView.swift
// Gank
//
// Created by 魏星 on 16/7/24.
// Copyright © 2016年 wx. All rights reserved.
//
import UIKit
@IBDesignable
class CardView: UIView {
@IBInspectable var cornerRadius: CGFloat = 2
@IBInspectable var shadowOffsetWidth: CGFloat = 0
@IBInspectable var shadowOffsetHeight: CGFloat = 0.5
@IBInspectable var shadowColor: UIColor? = UIColor.grayColor()
@IBInspectable var shadowOpacity: Float = 0.2
override func layoutSubviews() {
layer.cornerRadius = cornerRadius
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius)
layer.masksToBounds = false
layer.shadowColor = shadowColor?.CGColor
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight);
layer.shadowOpacity = shadowOpacity
layer.shadowPath = shadowPath.CGPath
}
}