Jatis-iOS
需求
- iOS 10.2(最低)- iOS 12.2(推荐)
- Swift 4.2
- XCode 10
安装
Jatis-iOS 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'Jatis-iOS' , '0.2.3.4' ~> Update of JatisTextView
pod 'Jatis-iOS' , '0.2.4.1' ~> Update of JatisDatePicker
功能
- 横幅
- 阴影
- 文本框
- 文本视图
- 日期选择器
概述
如何使用
1. 导入API
import Jatis_iOS
2. 添加横幅
let jatisBanner = JatisBanner()
firstBannerView.layoutIfNeeded()
jatisBanner.images = images
jatisBanner._id = _id
jatisBanner.aspectRatio = 9/16
jatisBanner.animate = true
jatisBanner.cornerRadius = 20
jatisBanner.size = firstBannerView.bounds.size
jatisBanner.animationInterval = 3.0
jatisBanner.reloadBanner()
firstBannerView.addSubview(jatisBanner)
firstBannerView.addRoundShadow(fillColor: .white, cornerRadius: 20,
shadowColor: .black, shadowOpacity: 0.9, shadowOffSet: CGSize(width: 4, height: 5),
shadowRadius: 15, scale: 1)
jatisBanner.tag = 1
jatisBanner.delegate = self
self.firstBannerView.addSubview(jatisBanner)
3. 添加阴影
firstBannerView.addRoundShadow(fillColor: .white,
cornerRadius: 50,
shadowColor: .black,
shadowOpacity: 0.8,
shadowOffSet: CGSize(width: -5, height: 2),
shadowRadius: 5,
scale: 1)
4. 点击图片时处理动作
extension ViewController : JatisBannerProtocol {
func didSelectBanner(_ data: String, tagBanner : Int) {
print("\(data) & \(tagBanner)")
}
}
5. 添加TextField
@IBOutlet var textFieldView: UIView!
@IBOutlet var labelView: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
self.generateTextFieldView()
}
func generateTextFieldView(){
var usernameTextfield = JatisTextField()
usernameView.layoutIfNeeded()
usernameTextfield.tagTextfield = 1
usernameTextfield.textPlaceholder = "Username"
usernameTextfield.size = usernameView.bounds.size
usernameTextfield.fontPlaceholder = UIFont(name: "Futura", size: 14)!
usernameTextfield.textColor = .darkText
usernameTextfield.doneButtonColor = .blue
usernameTextfield.placeHolderBeforeColor = .lightGray
usernameTextfield.labelPlaceholder.textAlignment = .left
usernameTextfield.textField.textAlignment = .left
usernameTextfield.delegate = self
usernameTextfield.setJatisTextField()
usernameView.addSubview(usernameTextfield)
}
6. 添加弹出表格
class TablePopUpViewController: UIViewController {
let popUpTable = JatisPopUpTable()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func actShowTable(_ sender: Any) {
popUpTable.parentSize = self.view.frame.size
popUpTable.tableSize = CGSize(width: 300, height: 300)
popUpTable.center = self.view.center
popUpTable.strings = ["a","b","c"]
popUpTable.title = "aaa"
popUpTable.maximumDisplayedCell = 3
popUpTable.formatPopUp()
popUpTable.delegate = self
self.view.addSubview(popUpTable)
}
}
extension TablePopUpViewController: JatisPopUpTableProtocol {
func didSelect(_ data: String, row : Int) {
print(data)
self.popUpTable.removeFromSuperview()
}
}
7. 添加 TextView
class TextViewVC: UIViewController {
@IBOutlet var txView1: UIView!
@IBOutlet var txView2: UIView!
let textView1 = JatisTextView()
let textView2 = JatisTextView()
var stringUsername : String = ""
var stringPassword : String = ""
override func viewDidLoad() {
super.viewDidLoad()
self.generateTextView()
// Do any additional setup after loading the view.
}
func generateTextView(){
txView1.layoutIfNeeded()
textView1.tagTextView = 1
textView1.textPlaceholder = "Username"
textView1.size = txView1.bounds.size
textView1.fontPlaceholder = UIFont(name: "Futura", size: 10)!
textView1.textColor = .darkText
textView1.doneButtonColor = .orange
textView1.placeHolderBeforeColor = .lightGray
textView1.delegate = self
textView1.borderStyle = .none
textView1.isUnderlined = true
self.textView1.backgroundColor = .darkGray
textView1.setJatisTextView()
txView1.addSubview(textView1)
txView2.layoutIfNeeded()
textView2.tagTextView = 2
textView2.textPlaceholder = "Password"
textView2.size = txView2.bounds.size
textView2.fontPlaceholder = UIFont(name: "Futura", size: 10)!
textView2.textColor = .darkText
textView2.doneButtonColor = .orange
textView2.placeHolderBeforeColor = .lightGray
textView2.delegate = self
textView2.labelPlaceholder.textAlignment = .center
textView2.textView.textAlignment = .center
self.textView2.backgroundColor = .darkGray
textView2.setJatisTextView()
txView2.addSubview(textView2)
}
}
extension TextViewVC : JatisTextViewProtocol {
func didJatisTextViewBeginEditing(_ data: String, tagTextView: Int) {
print("did begin : \(data)")
}
func didJatisTextViewEndEditing(_ data: String, tagTextView: Int) {
print("did end : \(data)")
}
func didJatisTextViewChange(_ data: String, tagTextView: Int) {
print("did change : \(data)")
}
func didJatisTextViewShouldEnd(_ data: String, tagTextView: Int) -> Bool {
print("did begin : \(data)")
if tagTextView == 1 {
return data.lowercased().contains("first") || data == ""
}
return true
}
}
8. Action 处理 TextField
extension ViewController : JatisTextFieldProtocol {
func didJatisTextBeginEditing(_ data: String, tagTextField: Int) {
}
func didJatisTextEndEditing(_ data: String, tagTextField: Int) {
}
func didJatisTextChange(_ data: String, tagTextField: Int) {
}
}
9. JatisDatePicker 的 Action 处理
class DatePickerVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
JatisDatePicker.delegate = self
}
@IBAction func showDatePicker(_ sender: UIButton) {
JatisDatePicker.tintButtonColor = .red
JatisDatePicker.animationTime = 0.25
JatisDatePicker.show(nil, nil)
}
}
extension DatePickerVC: JatisDatePickerDelegate {
func getSelectedDate(date: Date) {
lbDate.text = date.convertTo(format: "dd-MMM-yyyy")
}
}
GIF 动画
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
作者
古特·布迪,[email protected] 特尔塔·AR,[email protected]
许可证
Jatis-iOS 以 MIT 许可证发布。更多信息请参阅 LICENSE 文件。