2014-01-05 35 views
1

我想創建一個UITextField像找到iPhone。如何創建一個像查找iphone一樣的UITextField

我用於UITextField後續代碼:

UIBezierPath *maskPathBotton = [UIBezierPath bezierPathWithRoundedRect:txtSenha.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(8.0, 8.0)];

txtSenha.borderStyle=UITextBorderStyleNone; 

CAShapeLayer *maskLayerBotton = [CAShapeLayer layer]; 
maskLayerBotton.frame = txtSenha.bounds; 
maskLayerBotton.path = maskPathBotton.CGPath; 
maskLayerBotton.fillColor=[UIColor whiteColor].CGColor; 
maskLayerBotton.strokeColor=[UIColor lightGrayColor].CGColor; 
maskLayerBotton.lineWidth=1.5; 

[txtSenha.layer addSublayer:maskLayerBotton]; 

但結果不太好。

在角落裏,筆畫比其他線條略有不同。我如何創建相同的UITextField。對不起,我的英文,沒有圖片,我沒有足夠的聲譽來上傳圖片。

編輯: 的UITextField從查找iPhone
enter image description here

而這,就是我可以。

enter image description here

+0

此行

textField.borderStyle = UITextBorderStyleRoundedRect; 

相反,它是根本不清楚你正在嘗試做的。你是否試圖創建一個具有UITextView外觀的自定義視圖,以及圍繞它的框? –

+0

這就像兩個UITextField together.I更新與圖像的鏈接的帖子。 – Marlon

+0

如果我沒有錯,它是uitextfield在side cell中的一個可用視圖。 –

回答

0
如果你想圓角試試這個

textField.layer.cornerRadius = 10; 

一定要包括#import <QuartzCore/QuartzCore.h>訪問此

或從你的代碼

刪除的

[textField setBackgroundColor:[UIColor clearColor]]; 
[textField.layer setBorderColor:[UIColor grayColor].CGColor]; 
[textField.layer setBorderWidth:1.0]; 
+0

我可以這樣 「textField.layer.cornerRadius = 10;」 因爲我只想在第一個textField的左上角和右下角以及第二個textField的左下角和右下角進行圓角。 – Marlon

相關問題