zoukankan      html  css  js  c++  java
  • iOS-textfield控制光标开始位置

    //    UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 50)];
    //    paddingView1.backgroundColor = [UIColor lightGrayColor];
    //    self.phoneTextField .leftView = paddingView1;
    //    self.phoneTextField.leftViewMode = UITextFieldViewModeAlways;
    //    [self.view addSubview:paddingView1];
    //    
    //    self.phoneTextField = [[UITextField alloc]initWithFrame:CGRectMake(10, 0, self.view.frame.size.width,textFieldH )];
    //    self.phoneTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"手机" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //    self.phoneTextField.delegate = self;
    //    self.phoneTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    //    self.phoneTextField.returnKeyType = UIReturnKeyDone;
    //    [paddingView1 addSubview:self.phoneTextField];

    这是第一种办法,就是添加leftview

    第二种就是自定义UItextField

    #import <UIKit/UIKit.h>

    @interface textField : UITextField

    //控制 placeHolder 的位置,左右缩 10
    - (CGRect)textRectForBounds:(CGRect)bounds;

    // 控制文本的位置,左右缩 10
    - (CGRect)editingRectForBounds:(CGRect)bounds;
    @end
    textField.m

    #import "textField.h"

    @implementation textField

    - (CGRect)textRectForBounds:(CGRect)bounds {
        return CGRectInset( bounds , 10*1 , 0 );
    }

    // 控制文本的位置,左
    - (CGRect)editingRectForBounds:(CGRect)bounds {
        return CGRectInset( bounds , 10*1 , 0 );
    }
    @end

  • 相关阅读:
    1. 规范说明
    Swing Jtable 添加checkbox列
    ubuntu 右键添加打开终端
    关闭ubuntu中的”System Program Problem Detected”提示
    activemq和mqtt消息总线
    Swing 自定义日期控件
    Swing Jtable 设置背景色
    Swing Jtable 网格线设置
    Java Swing Jtable 单元格不可编辑
    Java Swing JTable 设置隔行变色
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5535287.html
Copyright © 2011-2022 走看看