objective c-UITextField遇到问题

问题描述

UITextField遇到问题

创建了UITextField,具体代码:

UItextField *mobileNumberField = [[UITextField alloc] initWithFrame:CGRectMake(10, 195, 300, 41)];
mobileNumberField.delegate = self;
mobileNumberField.borderStyle = UITextBorderStyleRoundedRect;
[mobileNumberField.layer setCornerRadius:14.0f];
mobileNumberField.placeholder = @"Mobile Number";
[self.paymentsHomeView addSubview:mobileNumberField];

但是显示的效果是这样:

不知道为什么框会断开。请高手帮忙改成这样的效果:

解决方案

很简单,删除这行:

mobileNumberField.borderStyle = UITextBorderStyleRoundedRect;

然后再加上这些:

[mobileNumberField setBackgroundColor:[UIColor whiteColor]];
[mobileNumberField.layer setBorderColor:[UIColor grayColor].CGColor];
[mobileNumberField.layer setBorderWidth:1.0];

解决方案二:

相信这个代码能帮你

 UITextField *mobileNumberField = [[UITextField alloc] initWithFrame:CGRectMake(10, 195, 300, 41)];
    mobileNumberField.delegate = self;
    mobileNumberField.layer.borderWidth = 1.0f;
    mobileNumberField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    mobileNumberField.
//    mobileNumberField.borderStyle = UITextBorderStyleRoundedRect;
    [mobileNumberField.layer setCornerRadius:14.0f];
    mobileNumberField.placeholder = @"Mobile Number";
    [self.paymentsHomeView addSubview:mobileNumberField];
时间: 2024-09-04 18:24:12

objective c-UITextField遇到问题的相关文章

objective c-设置UItextfield边框颜色

问题描述 设置UItextfield边框颜色 iphone中,在编辑文本时怎么设置UITextView的边框颜色? 下面的代码没有实现. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { textField.layer.borderColor=[[UIColor cyanColor] CGColor]; } 解决方案 加上:#Import <QuartzCore/QuartzCore.h> 用下面的代码就行: - (B

objective c-从view1中修改view2的UItextField

问题描述 从view1中修改view2的UItextField 在ViewController中,修改SecondViewController的UITextView.text 如果它是NSString类型可以这么修改: SVC.string = @"test"; 出现两个问题: messageBox.text没有修改 SVC.messageBox.text 返回(null) ViewController.m: SecondViewController *SVC = [[SecondVi

UITableView中cell里的UITextField不被弹出键盘挡住

UITableView中cell里的UITextField不被弹出键盘挡住    本人视频教程系类   iOS中CALayer的使用   效果如下: 源码: EditCell.h 与 EditCell.m // // EditCell.h // Cell // // Created by YouXianMing on 14/12/18. // Copyright (c) 2014年 YouXianMing. All rights reserved. // #import <UIKit/UIKit

触摸非输入区(背景)使UITextField(UISearchBar)键盘消失的方法

在iOS上出现软键盘后,希望点击非键盘部分,隐藏键盘,即使键盘消失的方法讨论. 第一种方法:增加一个button,相应touch down事件,隐藏键盘.这种方法,太山寨了.为了相应一个事件增加一个button太不值得的. 第二种方法:在背景图片上添加Tap事件,相应单击处理.这种方法,很好代替了button方式,但是如果UI上没有背景图片,这种方法又回到到第一种山寨的方法行列中. // Implement viewDidLoad to do additional setup after loa

用Dojo Objective Harness对Web 2.0应用程序进行单元测试

单元测试是保证软件开发质量的一个重要部分,对于敏捷和极限编程开发方法尤其如此.通常,对 Web 2.0 客户端用户界面进行自动的单元测试很困难,所以很少有人去做尝试.然而,Dojo 提供了一个单元测试工具,借此可以评估 JavaScript 的功能及用户界面的可视性.经过这个工具彻底测试过的用户界面最终包含的 Bug 数量会极大的减少.本文阐述了 Dojo Objective Harness (DOH) 的主要特点并通过与其它 Web 2.0 应用程序测试工具的比较展示了其强大的功能. 单元测试

iOS中UITextField 使用全面解析

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

Objective C从远程url下载图片方法汇总

  本文给大家分享了2则使用Objective C从远程url下载图片的方法,都是个人项目中使用的,汇总下推荐给大家,有需要的小伙伴可以参考下. Objective C从远程url下载图片 ? 1 2 3 4 5 6 7 8 - (UIImage *) getImageFromURL: (NSString *)theURL { UIImage *theImage = NULL; NSString *imageFileName = [BT_strings getFileNameFromURL:th

iPhone objective c 截屏代码

  objective c 截屏代码 -(void)save{ UIGraphicsBeginImageContext(mybackgroundview.bounds.size); //currentView 当前的view [mybackgroundview.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UITextField使用的一些细节

UITextField使用的一些细节 这篇博文是我自己使用UITextField的一些总结,并没有太多营养,并会持续更新. 2014.9.15 -------------------------------------------------------------------------------------------------------------------------------------- 源码: // // RootViewController.m // UITextFie

iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法

转自:http://blog.csdn.net/xiaotanyu13/article/details/7711954 iOS上面对键盘的处理很不人性化,所以这些功能都需要自己来实现, 首先是点击return和屏幕隐藏键盘 这个首先引用双子座的博客 http://my.oschina.net/plumsoft/blog/42545,他的文章写的很好,对大家的理解很有好处. 在 iOS 程序中当想要在文本框中输入数据,轻触文本框会打开键盘.对于 iPad 程序,其键盘有一个按钮可以用来关闭键盘,但