ZCardView 0.1.0

ZCardView 0.1.0

Sudan Suwal维护。



ZCardView 0.1.0

  • sxudan

ZCardView

ZCardView是一个简单的卡片视图,您可以修改卡片半径和阴影。您可以修改卡片的半径和阴影。ZCardView使您更容易并节省大量开发时间。

示例

使用Storyboard

1. 添加一个UIView


2. 前往Identity Inspector,根据需要更改类名为ZCardViewZCardButton

3. 前往Attributes Inspector,现在您可以更改某些卡片视图属性。

注意

为了使imageView圆形并带有阴影,在卡片视图中添加一个imageView,并将cardview的containsImageView布尔属性设置为true。

以编程方式添加

override func viewDidLoad() {
    super.viewDidLoad()
    
    //Create a Card
    let card = ZCardView(frame: CGRect(x: 0, y: 0, width: 250, height: 100))
    card.backgroundColor = .white
    card.shadowColor = .darkGray
    card.radius = card.frame.height / 2.0
    card.shadowRadius = 10
    card.backgroundColor = .purple
    self.view.addSubview(card)
    
    //label
    let lbl = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 24))
    lbl.text = "Programmatic Card View"
    lbl.textColor = .white
    card.addSubview(lbl)
    lbl.sizeToFit()
    lbl.center = card.center
    
    //constraints
    card.translatesAutoresizingMaskIntoConstraints = false
    card.widthAnchor.constraint(equalToConstant: card.frame.width).isActive = true
    card.heightAnchor.constraint(equalToConstant: card.frame.height).isActive = true
    card.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
    card.topAnchor.constraint(equalTo: cardButton.bottomAnchor, constant: 24).isActive = true
    
    
  }

属性

  1. radius: CGFloat 调整卡片半径。
  2. shadowColor: UIColor 卡片的阴影颜色。
  3. shadowRadius: CGFloat 卡片的阴影半径。
  4. shadowOffsetX: CGFloat 阴影的X偏移量。
  5. shadowOffsetY: CGFloat 阴影的Y偏移量。
  6. shadowOpacity: CGFloat 阴影的不透明度。
  7. containsImageView: Bool 如果卡片包含一个子视图ImageView。

安装

ZCardView 通过 CocoaPods 可用。要安装,只需在 Podfile 中添加以下行

pod 'ZCardView'

作者

sudayn, [email protected]

许可协议

ZCardView 采用 MIT 许可协议。有关更多信息,请参阅 LICENSE 文件。