LabelTapGesture 1.1.0

LabelTapGesture 1.1.0

Visarut Tippun 维护。



  • 作者:
  • Visarut Tippun

LabelTapGesture 这是一个用于设置自定义超链接样式的 UILabel 的扩展,并在点击链接时提供交互。

📲安装

LabelTapGesture 可在 CocoaPods 上获取

pod 'LabelTapGesture'

📝如何

代码实现

import LabelTapGesture

示例条款和条件标签。

@IBOutlet var termsConditionLabel: UILabel!

// Example Terms and Conditions text.
let text:String = "By signing up you confirm your agreement with our terms and conditions. We’ll never share your information"
let textAttributes:[NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 16)]
        
let rangeText:String = "terms and conditions"
let rangeTextAttributes:[NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 16),
                                                          .foregroundColor: UIColor.blue,
                                                          .underlineStyle: NSUnderlineStyle.single]

self.termsConditionLabel.addTapGesture(text: text, textAttributes: textAttributes,
                                       rangeText: rangeText, rangeTextAttributes: rangeTextAttributes) {
    // Handles when tapping the rangeText on the label.
}

📋要求

  • iOS 10.0+
  • Xcode 11+
  • Swift 5.1+