diff --git a/PPBadgeView/objc/PPBadgeControl.h b/PPBadgeView/objc/PPBadgeControl.h index d500cac..59ca88c 100644 --- a/PPBadgeView/objc/PPBadgeControl.h +++ b/PPBadgeView/objc/PPBadgeControl.h @@ -49,6 +49,10 @@ NS_ASSUME_NONNULL_BEGIN /// 记录Badge的偏移量 Record the offset of Badge @property (nonatomic, assign) CGPoint offset; + +/// 自定义角标Label CustomLabel +@property (nonatomic, strong) UILabel *textLabel; + @end NS_ASSUME_NONNULL_END diff --git a/PPBadgeView/objc/PPBadgeControl.m b/PPBadgeView/objc/PPBadgeControl.m index 4af237b..51252c1 100644 --- a/PPBadgeView/objc/PPBadgeControl.m +++ b/PPBadgeView/objc/PPBadgeControl.m @@ -22,7 +22,6 @@ @interface PPBadgeControl () -@property (nonatomic, strong) UILabel *textLabel; @property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIColor *badgeViewColor; @property (nonatomic, strong) NSLayoutConstraint *badgeViewHeightConstraint; diff --git a/PPBadgeView/swift/PPBadgeControl.swift b/PPBadgeView/swift/PPBadgeControl.swift index 77dcafb..7bbcf67 100644 --- a/PPBadgeView/swift/PPBadgeControl.swift +++ b/PPBadgeView/swift/PPBadgeControl.swift @@ -28,7 +28,7 @@ open class PPBadgeControl: UIControl { /// Badge伸缩的方向, Default is PPBadgeViewFlexModeTail public var flexMode: PPBadgeViewFlexMode = .tail - private lazy var textLabel: UILabel = UILabel() + public lazy var textLabel: UILabel = UILabel() private lazy var imageView: UIImageView = UIImageView() diff --git a/PPBadgeViewSwift/PPBadgeViewSwift/Classes/Controllers/PPViewController2.swift b/PPBadgeViewSwift/PPBadgeViewSwift/Classes/Controllers/PPViewController2.swift index e6574a6..fbe6bfb 100644 --- a/PPBadgeViewSwift/PPBadgeViewSwift/Classes/Controllers/PPViewController2.swift +++ b/PPBadgeViewSwift/PPBadgeViewSwift/Classes/Controllers/PPViewController2.swift @@ -20,6 +20,19 @@ class PPViewController2: UIViewController { testView.pp.addBadge(number: 10) view.addSubview(testView) + let testView2 = UIView(frame: CGRect(x: 100, y: 250, width: 100, height: 100)) + testView2.backgroundColor = UIColor.blue + testView2.pp.badgeView.textLabel.text = "哈哈" + testView2.pp.badgeView.textLabel.font = UIFont.systemFont(ofSize: 10) + testView2.pp.setBadge(height: 15) + view.addSubview(testView2) + + let testView3 = UIView(frame: CGRect(x: 100, y: 400, width: 100, height: 100)) + testView3.backgroundColor = UIColor.blue + let attStr = NSAttributedString.init(string: "hello") + testView3.pp.badgeView.textLabel.attributedText = attStr + view.addSubview(testView3) + } override func didReceiveMemoryWarning() {