YTFloatingTitleTextField 0.1.1

YTFloatingTitleTextField 0.1.1

ldbchan 维护。



  • 作者
  • ldbchan

YTFloatingTitleTextField

CI Status Version License Platform

YTFloatingTitleTextField 是 Objective-C 中实现的一个继承自 UITextField 的子类。它是可定制的,易于使用,并支持通过代码或 Interface Builder 使用。使用 YTFloatingTitleTextField,您将能够

  • 在编辑时启用浮动标题
  • 启用显示下划线
  • titleplaceholder 使用不同的文本
  • 为相应的状态(正常或错误)使用不同的样式

使用方法

通过 Interface Builder

  • UITextField 组件拖到您的视图控制器中
  • 转到 Identity Inspector > Custom Class 并将类名更改为 YTFloatingTitleTextField

使用 Interface Builder 的优势——我们为您设置了一些默认配置

  • title 将设置为与 placeholder 相同
  • normalTextColor 将设置为与 textColor 相同
  • normalTextFont 将设置为与 font 相同
  • normalLineColor 将设置为与 tintColor 相同

在代码中

在代码中使用也是极其简单的

YTFloatingTitleTextField *textField = [[YTFloatingTitleTextField alloc]
initWithFrame:CGRectMake(40, 150, 200, 60)];
textField.title = @"Name";
textField.placeholder = @"What's your name?";
textField.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:textField];

示例

要运行示例项目,请克隆存储库,然后首先从示例目录中运行 pod install

要求

iOS 8.0+

安装

CocoaPods

如果尚未安装CocoaPods,您可以通过运行以下命令来安装:

$ gem install cocoapods

然后,只需将以下行添加到您的Podfile中:

pod 'YTFloatingTitleTextField'

许可证

YTFloatingTitleTextField 在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。