Latest1.0.1
Homepagehttps://github.com/yscode001/YSBadge
LicenseMIT
Platformsios 8.0
FrameworksUIKit
Authors

自定义视图角标_swift编写,使用简单,样式灵活。

YSBadge

环境

swift 4

iOS 8+

arm 64

使用步骤

1、导入框架

pod 'YSBadge'

2、导入命名空间

import YSBadge

使用示例

import UIKit

import YSBadge

class ViewController: UIViewController {

    private lazy var testView:UIView = {

        let frame = CGRect(x: 100, y: 100, width: 100, height: 100)

        let v = UIView(frame: frame)

        v.backgroundColor = UIColor.yellow

        return v

    }()

    private lazy var testBtn:UIButton = {

        let btn = UIButton(type: .contactAdd)

        btn.addTarget(self, action: #selector(btnClick), for: .touchUpInside)

        return btn

    }()

    override func viewDidLoad() {

        super.viewDidLoad()

        view.addSubview(testView)

        view.addSubview(testBtn)

        testBtn.frame.origin = CGPoint(x: 140, y: 250)

    }

    @objc private func btnClick(){

    // 设置badge样式

    // font:字体

    // textColor:文字颜色

    // badgeColor:填充颜色

    // borderColor:边框颜色

    // borderWidth:边框线宽

    // minDiameter:最小直径

    // horizontalOffset:水平偏移量

    // verticalOffset:垂直偏移量

    // innerSpaceFromBorder:文字与边框的间距

    // position:位置

    testView.ysBadgeView.setStyle(font: UIFont.systemFont(ofSize: 12), textColor: UIColor.white, badgeColor: UIColor.red, borderColor: nil, borderWidth: nil, minDiameter: 20, horizontalOffset: nil, verticalOffset: nil, innerSpaceFromBorder: nil, position: .topTrailing)

    // 设置badge值

    testView.ysBadgeView.badgeValue += 9

    }

}

Latest podspec

{
    "name": "YSBadge",
    "version": "1.0.1",
    "summary": "u81eau5b9au4e49u89d2u6807",
    "homepage": "https://github.com/yscode001/YSBadge",
    "license": "MIT",
    "authors": {
        "ys": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/yscode001/YSBadge.git",
        "tag": "1.0.1"
    },
    "source_files": "YSBadge/YSBadge/YSBadge/*.swift",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This