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

  • 相关阅读:
    css div中加入滚动条
    oracle创建表主键触发器
    SQL Server 日志满的处理方法(转)
    Asp.net 设置页面自动刷新
    设置DataGrid可读取中隐藏列数据
    用JavaScript获取Asp.net服务器端控件CheckBoxList的选中值数组(转)
    AutoLISP查询椭圆的相关属性
    AutoLISP查询圆弧的相关属性
    关于性格内向者的10个误解
    AutoLISP查询图元信息
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5535287.html
Copyright © 2011-2022 走看看