(iOS)修改UITextField高度

修改UITextField高度

===

---

## 是否可以通过修改frame改变高度

网上流传的代码中使用如下一份代码:

//    以下代码任然不能改变UITextField高度

CGRect rect = _userNameField.bounds;

rect.size.height = 88;

rect.size.width = 20;

_userNameField.bounds = rect;

所以不可以。

---

## 通过自定义子类实现修改UITextField高度

在子类中覆盖``- (CGRect)borderRectForBounds:(CGRect)bounds``方法,即可

/**

*  通过以下代码实现设置文本框高度

*  44是所希望的高度

*/

- (CGRect)borderRectForBounds:(CGRect)bounds

{

bounds.size.height = 44;

return bounds;

}

>### Parameters

>* bounds

>

>The bounding rectangle of the receiver.

>

>* Return Value

>

>The border rectangle for the receiver.

时间: 2024-08-25 21:07:41

(iOS)修改UITextField高度的相关文章

iOS修改UITextField的Placeholder字体颜色

修改UITextField的Placeholder字体颜色有一下两张方式可以达到效果. 第一种: UIColor *color = [UIColor whiteColor]; textfield.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}]; 第二种: [textfield set

iOS利用storyboard修改UITextField的placeholder文字颜色

最近有个需求需要修改UITextField的placeholder文字颜色,在网上找发现有用代码修改的,但是考虑到更加优雅的实现,所以尝试着在storyboard中直接实现,结果竟然真的成功了(原谅我太小白),实现的位置如下: 具体步骤: 1.在User Defined Runtime Attributes中添加一个Key. 2.输入Key Path(这里我们输入_placeholderLabel.textColor). 3.选择Type,有很多种(这里我们选择Color) 4.设置Value(

[转]iOS中UITextField 使用全面解析

001//初始化textfield并设置位置及大小002  UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];003  004//设置边框样式,只有设置了才会显示边框样式 005  text.borderStyle = UITextBorderStyleRoundedRect;006 typedef enum {007    UITextBorderStyleNone,008   

IOS的UITextField,UIButton,UIWebView的一些属性介绍和IOS图片资源的使用技巧

有时候UI给开发的资源跟实际的frame不一致,这个时候我们就要去拉伸图片 UIImage* image = [[UIImage imageNamed:@"text_field_bg.png"] stretchableImageWithLeftCapWidth:20 topCapHeight:0]; //stretchableImageWithLeftCapWidth使图片有拉伸效果 UITextField的属性介绍: UITextField* field = [[UITextFiel

iOS修改默认Xcode版本的方法

电脑中装了二个xcode版本,一个是xcode6-beta,一个是xcode5.1.1,每次打开工程时,默认是用xcode6-beta打开.在简介中修改打开方式也没用,没来在stackoverflow中找到答案 After reading about LaunchServices in OS X I have finally found the solution, thanks for the hint @peter-m. To modify files association for cert

iOS—修改AFNetworking源文件可接收text/plain的方法

iOS—修改AFNetworking源文件可接收text/plain的方法 在使用AFNetworking的时候可能会碰到下面的错误: { status code: 200, headers { "Content-Length" = 14; "Content-Type" = "text/plain;charset=utf-8"; Date = "Thu, 22 May 2014 10:37:50 GMT"; Server =

iOS Dev (59) 高度自适应的UITextView

iOS Dev (59) 高度自适应的UITextView 作者:阿锐 地址:http://blog.csdn.net/prevention - 如下 _inputTextView 为一个 UITextView 实例.首先要设置它的 delegate,然后要在你的头文件的 interface 声明中加上 UITextViewDelegate. _inputTextView.delegate = self; 在 implementation 中实现如下方法: - (void)textViewDid

修改 UITextfield placeholder 颜色

_password = [[UITextField alloc]init]; _password.font = k18Font; _password.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@" 密码" attributes:@{NSForegroundColorAttributeName:kBlackColor}]; ***************** 而且 UITextField 比 UIL

iOS 修改toolbar里面文字的字体和大小

使用NSDictionaty来设置文本的属性: NSDictionary * attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Heiti SC" size:20]}; [confirmBarButton setTitleTextAttributes:attributes forState:UIControlStateNormal]; 完整代码: self.inputToolbar = [[UIToolbar allo