Skip to content

Commit

Permalink
1、添加键盘输入类型;
Browse files Browse the repository at this point in the history
  • Loading branch information
choiceyou committed May 2, 2018
1 parent 11e0e79 commit 43df37d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions FWPopupView/FWPopupView/FWDemoViewController.swift
Expand Up @@ -79,14 +79,14 @@ extension FWDemoViewController {
let vProperty = FWAlertViewProperty()
vProperty.detailColor = UIColor.red

let alertView = FWAlertView.alert(title: "标题", detail: "描述描述描述描述描述描述描述描述描述描述", inputPlaceholder: nil, customView: nil, items: items, vProperty: vProperty)
let alertView = FWAlertView.alert(title: "标题", detail: "描述描述描述描述描述描述描述描述描述描述", inputPlaceholder: nil, keyboardType: .default, customView: nil, items: items, vProperty: vProperty)
alertView.show()
break
case 3:
let items = [FWPopupItem(title: "取消", itemType: .normal, isCancel: true, handler: block),
FWPopupItem(title: "确定", itemType: .normal, isCancel: false, handler: block)]

let alertView = FWAlertView.alert(title: "标题", detail: "带输入框", inputPlaceholder: "请输入...", customView: nil, items: items)
let alertView = FWAlertView.alert(title: "标题", detail: "带输入框", inputPlaceholder: "请输入...", keyboardType: .default, customView: nil, items: items)
print("点击了确定")
alertView.show(completionBlock: { (popupView, isCompletion) in
print("点击了取消")
Expand All @@ -98,7 +98,7 @@ extension FWDemoViewController {
// 注意:添加自定义的视图,需要设置确定的Frame值
let customImageView = UIImageView(image: UIImage(named: "audio_bgm_4"))

let alertView = FWAlertView.alert(title: "标题", detail: "带自定义视图", inputPlaceholder: nil, customView: customImageView, items: items)
let alertView = FWAlertView.alert(title: "标题", detail: "带自定义视图", inputPlaceholder: nil, keyboardType: .default, customView: customImageView, items: items)
print("点击了确定")
alertView.show(completionBlock: { (popupView, isCompletion) in
print("点击了取消")
Expand Down
29 changes: 15 additions & 14 deletions FWPopupView/FWPopupView/FWPopupView/FWAlertView.swift
Expand Up @@ -33,7 +33,7 @@ open class FWAlertView: FWPopupView {
private var commponenetArray: [UIView] = []


/// 类初始化方法
/// 单个按钮的弹窗
///
/// - Parameters:
/// - title: 标题
Expand All @@ -44,11 +44,11 @@ open class FWAlertView: FWPopupView {

let alertView = FWAlertView()
let items = [FWPopupItem(title: alertView.property.defaultTextOK, itemType: .normal, isCancel: false, handler: confirmBlock)]
alertView.setupUI(title: title, detail: detail, inputPlaceholder: nil, customView: nil, items: items)
alertView.setupUI(title: title, detail: detail, inputPlaceholder: nil, keyboardType: .default, customView: nil, items: items)
return alertView
}

/// 类初始化方法
/// 两个按钮的弹窗
///
/// - Parameters:
/// - title: 标题
Expand All @@ -62,26 +62,26 @@ open class FWAlertView: FWPopupView {
let items = [FWPopupItem(title: alertView.property.defaultTextCancel, itemType: .normal, isCancel: true, handler: cancelBlock),
FWPopupItem(title: alertView.property.defaultTextConfirm, itemType: .normal, isCancel: false, handler: confirmBlock)]

alertView.setupUI(title: title, detail: detail, inputPlaceholder: nil, customView: nil, items: items)
alertView.setupUI(title: title, detail: detail, inputPlaceholder: nil, keyboardType: .default, customView: nil, items: items)
return alertView
}

/// 类初始化方法
/// 可带输入框的弹窗
///
/// - Parameters:
/// - title: 标题
/// - detail: 描述
/// - inputPlaceholder: 输入框提示文字。注意:没有输入框时该参数必须要为nil,反之为空或者字符串即可
/// - items: 点击按钮项
/// - Returns: self
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, items: [FWPopupItem]) -> FWAlertView {
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, keyboardType: UIKeyboardType, items: [FWPopupItem]) -> FWAlertView {

let alertView = FWAlertView()
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, customView: nil, items: items)
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, keyboardType: keyboardType, customView: nil, items: items)
return alertView
}

/// 类初始化方法
/// 可带输入框、自定义视图的弹窗
///
/// - Parameters:
/// - title: 标题
Expand All @@ -90,14 +90,14 @@ open class FWAlertView: FWPopupView {
/// - items: 点击按钮项
/// - customView: 自定义UI
/// - Returns: self
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, customView: UIView?, items: [FWPopupItem]) -> FWAlertView {
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, keyboardType: UIKeyboardType, customView: UIView?, items: [FWPopupItem]) -> FWAlertView {

let alertView = FWAlertView()
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, customView: customView, items: items)
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, keyboardType: keyboardType, customView: customView, items: items)
return alertView
}

/// 类初始化方法
/// 可带输入框、自定义视图的弹窗,可设置Alert相关属性
///
/// - Parameters:
/// - title: 标题
Expand All @@ -107,13 +107,13 @@ open class FWAlertView: FWPopupView {
/// - customView: 自定义UI
/// - vProperty: FWAlertView的相关属性
/// - Returns: self
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, customView: UIView?, items: [FWPopupItem], vProperty: FWAlertViewProperty?) -> FWAlertView {
@objc open class func alert(title: String, detail: String, inputPlaceholder: String?, keyboardType: UIKeyboardType, customView: UIView?, items: [FWPopupItem], vProperty: FWAlertViewProperty?) -> FWAlertView {

let alertView = FWAlertView()
if vProperty != nil {
alertView.property = vProperty!
}
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, customView: customView, items: items)
alertView.setupUI(title: title, detail: detail, inputPlaceholder: inputPlaceholder, keyboardType: keyboardType, customView: customView, items: items)
return alertView
}

Expand All @@ -133,7 +133,7 @@ open class FWAlertView: FWPopupView {

extension FWAlertView {

private func setupUI(title: String?, detail: String?, inputPlaceholder: String?, customView: UIView?, items: [FWPopupItem]) {
private func setupUI(title: String?, detail: String?, inputPlaceholder: String?, keyboardType: UIKeyboardType, customView: UIView?, items: [FWPopupItem]) {

if items.count == 0 {
return
Expand Down Expand Up @@ -213,6 +213,7 @@ extension FWAlertView {
self.inputTF?.layer.borderColor = self.property.splitColor.cgColor
self.inputTF?.layer.borderWidth = self.property.splitWidth
self.inputTF?.layer.cornerRadius = self.property.cornerRadius
self.inputTF?.keyboardType = keyboardType

currentMaxY = self.inputTF!.frame.maxY

Expand Down
2 changes: 1 addition & 1 deletion FWPopupView/FWPopupView/FWPopupView/FWSheetView.swift
Expand Up @@ -34,7 +34,7 @@ open class FWSheetView: FWPopupView {
return sheetView
}

/// 类初始化方法
/// 类初始化方法,可设置Sheet相关属性
///
/// - Parameters:
/// - title: 标题
Expand Down

0 comments on commit 43df37d

Please sign in to comment.