SATextfield 0.1.7

SATextfield 0.1.7

Pankaj Bhalala 维护。



  • Solution Analyst

SATextField

该框架旨在扩展 UITextField 的功能。您可以使用下拉菜单、下划线、浮动文本框、信息视图、密码视图。此代码提供了一体化的工具来管理文本框。

入门指南

快速布局设计

以下是用于快速布局设计的某些类型

  • .underLine
  • .dashedLine
  • .border
  • .borderWithCornerRadius
  • .password
  • .floaty
  • .dropdown
  • .infoView

外观

textfield.type = .underline

alt text

textfield.type = .dashedLine

alt text

textfield.type = .border

alt text

textfield.type = .borderWithCornerRadius

alt text

textfield.type = .password

alt text

textfield.type = .floaty

alt text

textfield.isAutoDetectDirectionDropDown = true
textfield.type = .dropdown

下拉菜单自动检测方向(上显示/下显示)

使用 isAutoDetectDirectionDropDown = true //默认值为 false 下拉菜单将自动定义显示和隐藏的方向。

alt text

alt text

alt text

textfield.isAutoDetectDirectionInfoview = true
textfield.type = .infoView
textfield.infoViewText = "Sample Text"
textfield.infoViewBackColor = .darkGray

使用 isAutoDetectDirectionInfoview = true //默认值为 false 信息视图将自动定义显示和隐藏的方向。

alt text

先决条件

Swift 4.2

iOS 10*

Xcode 10

安装

使用 Pod

你想要像以下这样,在你的 Podfile 中添加 pod 'SATextfield'

target 'MyApp' do

  pod 'SATextfield'
  
end

使用 Carthage

Carthage 是一个去中心化的依赖关系管理器,它构建你的依赖关系,并为你提供二进制框架。

你可以使用以下命令通过 Homebrew 安装 Carthage

$ brew update
$ brew install carthage

要将 SATextfield 集成到你的 Xcode 项目中使用 Carthage,在 Cartfile 中指定它

github "sapankajbhalala/SATextfield" "master"

运行 "carthage update",构建框架,并将构建的 SATextfield.framework 拖动到你的 Xcode 项目中。

手动

如果你不想使用上述任何依赖关系管理器,你可以手动将 SATextfield 集成到你的项目中。只需从 拷贝你的项目目录中的源文件夹

如何使用?

import SATextfield

class VC1: UIViewController{
  @IBOutlet weak var textfield: SATextfield!
  
  override func viewDidLoad() {
    super.viewDidLoad()
    textfield.type = .underline //specify which type you want to use
  }
}

以下是一些自定义选项

// For .underline and .dashline type:
    textfield.lineWidth = 2
    textfield.lineColor = UIColor.darkGray
    
// For .border type:
    textfield.borderWidth = 2
    textfield.borderColor = UIColor.darkGray

// For .borderWithCornerRadius type:
    textfield.borderWidth = 2
    textfield.borderColor = UIColor.darkGray
    textfield.cornerRadius = 5
    
// For .infoView type:
    textfield.infoViewBackColor = UIColor.darkGray
    textfield.infoViewTextColor = UIColor.black
    textfield.infoViewText = "How to use this framework?"

// For .dropdown type:
    textfield.dropDownBackgroundColor = UIColor.darkGray
    textfield.dropDownOptions = ["One","Two","Three","Four","Five"]

SATextfieldDelegate

使用SATextfieldDelegate获取下拉选择值。

class ViewController: UIViewController, SATextfieldDelegate {
......
....
  textfield.textFieldDelegate = self
}

使用SATextfieldDelegate方法获取下拉选择值

// MARK: - SAtextField Delegate
  func dropDown(_ textfield: SATextfield, didSelectItem title: String) {
      print(title)
  }

作者

Solution Analyst

许可协议

MIT许可协议

版权所有 © 2019 Solution Analysts Pvt. Ltd.

在此特此许可,免费向任何获得此软件及其相关文档文件(统称为“软件”)副本的个人提供,无权使用、复制、修改、合并、发布、分发、转让和/或出售软件副本,以及允许向提供软件的个人这样做,前提是遵守以下条件:

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“原样”提供,不提供任何明示或暗示的担保,包括但不限于适销性、适用于特定目的和非侵犯性的担保。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任承担责任,无论这些责任是否源自合同、侵权或其他方式,无论是否与软件或软件的使用或其他方式有关。