1. 程式人生 > >ios App textField placeholder 信息上浮

ios App textField placeholder 信息上浮

ext label desc setup utl per loading idt atomic

textField placeholder 提示信息上浮

當輸入框 有文的時候 placeholder 信息就浮動到左上角。

只要繼承就行,不用附加調用代碼, 使用非常簡單。

tintFloatField

技術分享

代碼調用非常簡單

#import "RPFloatingPlaceholderTextField.h"
#import "RPFloatingPlaceholderTextView.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet RPFloatingPlaceholderTextField *titleField;
@property (weak, nonatomic) IBOutlet RPFloatingPlaceholderTextField *detailField;

@property (weak, nonatomic) IBOutlet RPFloatingPlaceholderTextField *localField;
@property (weak, nonatomic) IBOutlet RPFloatingPlaceholderTextField *cityField;

@property (weak, nonatomic) IBOutlet RPFloatingPlaceholderTextView *describeTextView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.titleField.floatingLabelActiveTextColor = [UIColor redColor];
    self.titleField.floatingLabelInactiveTextColor = [UIColor blueColor];
    
    self.detailField.floatingLabelActiveTextColor = [UIColor redColor];
    self.detailField.floatingLabelInactiveTextColor = [UIColor blueColor];
    
    
    
    self.localField.floatingLabelActiveTextColor = [UIColor redColor];
    self.localField.floatingLabelInactiveTextColor = [UIColor blueColor];
    
    self.cityField.floatingLabelActiveTextColor = [UIColor redColor];
    self.cityField.floatingLabelInactiveTextColor = [UIColor blueColor];

    
    
    self.describeTextView.placeholder = @"describe";
    self.describeTextView.floatingLabelActiveTextColor = [UIColor redColor];
    self.describeTextView.floatingLabelInactiveTextColor = [UIColor blueColor];
    
    self.describeTextView.layer.borderColor = [UIColor blackColor].CGColor;
    self.describeTextView.layer.borderWidth = 1;
    
}



@end

  

github 地址:https://github.com/lc081200/tintFloatField

ios App textField placeholder 信息上浮