![](/img/trans.png)
[英]How can I delay UINavigationController transitions in UIKit?
[英]How can I make a custom text field with UIKit?
我想創建具有不同背景圖像,顏色或大小的特殊文本字段。 我怎樣才能做到這一點?
在IB中,將一個View拖到當前視圖中,將其Custom Class
設置為您自己的類(可能是UITextField子類),然后開始添加自己的圖像等。
如果我的示例代碼有錯誤,請提前進行應用程序學,我已經有一段時間沒有做太多可可/ objective-c了,但這是解決問題的三種方法。
在UIView
以編程方式設置屬性
@interface MYView: UIView
{
}
@implementation MYView
{
- (void) loadView {
UITextField * text = [[UITextField alloc] init];
text.frame = CGRectMake(100, 170, 100, 30);
[text setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[text setBorderStyle:UITextBorderStyleBezel];
[self.view addSubview:text];
}
}
通過繼承-您可以在上面的視圖中使用繼承(也可以從IB使用)
@interface MYTextFied: UITextField
{
}
@implementation MYTextField
{
- (void) init {
self = [super init];
if (self != nil) {
[self setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[self setBorderStyle:UITextBorderStyleBezel];
}
return self;
}
}
在IB中,只需四處單擊,直到找到合適的菜單/窗格或查看此
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.