Swiftpack.co - feixue299/FXViewKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by feixue299.
feixue299/FXViewKit 0.4.0
快速构建常用的一些View
⭐️ 0
🕓 2 years ago
iOS
.package(url: "https://github.com/feixue299/FXViewKit.git", from: "0.4.0")

FXViewKit

Requirements

  • iOS 9.0+

Installation

CocoaPods

For FXViewKit, use the following entry in your Podfile:

pod 'FXViewKit', '~> 0.1.11'

Then run pod install.

Carthage

Make the following entry in your Cartfile:

github "feixue299/FXViewKit" ~>0.1.11

Then run carthage update.

Swift Package Manager

Create a Package.swift file.

let package = Package(
    dependencies: [
        .package(url: "https://github.com/feixue299/FXViewKit.git", from: "0.1.11")
    ],
    // ...
)

Example

import FXViewKit

class ViewController: UIViewController {

    let lrView = LeftRightView<UILabel, UIButton>()
    let tbView = TopBottomView<UILabel, UIButton>()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        lrView.backgroundColor = .systemPink
        lrView.leftView.text = "left"
        lrView.leftView.backgroundColor = .systemBlue
        lrView.rightView.addTarget(self, action: #selector(lrViewTap), for: .touchUpInside)
        lrView.rightView.backgroundColor = .green
        lrView.rightView.setTitle("right", for: .normal)
        
        lrView.translatesAutoresizingMaskIntoConstraints = false
        
        view.addSubview(lrView)
        NSLayoutConstraint.activate([
            lrView.leftAnchor.constraint(equalTo: view.leftAnchor),
            lrView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            lrView.heightAnchor.constraint(equalToConstant: 44),
            lrView.rightAnchor.constraint(equalTo: view.rightAnchor)
        ])
        
        tbView.backgroundColor = .systemPink
        tbView.topView.text = "top"
        tbView.topView.backgroundColor = .systemBlue
        tbView.bottomView.addTarget(self, action: #selector(tbViewTap), for: .touchUpInside)
        tbView.bottomView.backgroundColor = .green
        tbView.bottomView.setTitle("bottom", for: .normal)
        
        tbView.translatesAutoresizingMaskIntoConstraints = false
        
        view.addSubview(tbView)
        NSLayoutConstraint.activate([
            tbView.topAnchor.constraint(equalTo: view.topAnchor),
            tbView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            tbView.widthAnchor.constraint(equalToConstant: 60),
            tbView.bottomAnchor.constraint(equalTo: lrView.topAnchor)
        ])
        
    }

    @objc func lrViewTap() {
        lrView.edges.top = CGFloat(arc4random() % 10)
        lrView.edges.left = CGFloat(arc4random() % 10)
        lrView.edges.right = CGFloat(arc4random() % 10)
        lrView.edges.bottom = CGFloat(arc4random() % 10)
    }
    
    @objc func tbViewTap() {
        tbView.edges.top = CGFloat(arc4random() % 10)
        tbView.edges.left = CGFloat(arc4random() % 10)
        tbView.edges.right = CGFloat(arc4random() % 10)
        tbView.edges.bottom = CGFloat(arc4random() % 10)
    }

}

GitHub

link
Stars: 0
Last commit: 32 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics