zoukankan      html  css  js  c++  java
  • iPhone之UITextField缩进文本

    做应用的时候,经常用到文本框,自定义的文本框,往往都是在登录注册页面时用到UITextField。应用原型图上的文本框会稍微右缩进空几个空格的,看起来还好看些,当UItextField上直接用的话,那个光标会紧贴着左框,有些些不好看,下图比较:

    会好些!

    很简单,继承UITextfield,覆盖父类方法!

    #import <UIKit/UIKit.h>
    
    @interface InsetsTextField : UITextField
    - (CGRect)textRectForBounds:(CGRect)bounds;
    - (CGRect)editingRectForBounds:(CGRect)bounds;
    @end
    
    #import "InsetsTextField.h"
    
    @implementation InsetsTextField
    
    //控制文本所在的的位置,左右缩 10
    - (CGRect)textRectForBounds:(CGRect)bounds {
        return CGRectInset( bounds , 10 , 0 );
    }
    
    //控制编辑文本时所在的位置,左右缩 10
    - (CGRect)editingRectForBounds:(CGRect)bounds {
        return CGRectInset( bounds , 10 , 0 );
    }
    
    @end


    ok!




  • 相关阅读:
    go包初始化顺序
    go map
    go包管理
    C++ 线程池
    RAFT共识算法笔记
    最大子序列和
    常见网络攻击及其防御
    go常用标准库功能
    using代替typedef
    typename和class的区别
  • 原文地址:https://www.cnblogs.com/bbsno1/p/3268645.html
Copyright © 2011-2022 走看看