画像を textField rightView に設定してください
UITextField *textField = [[UITextField alloc] init];
[textField setRightViewMode:UITextFieldViewModeAlways];
textField.rightView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"asdsad.png"]];
中央の画像については、可能な限りカスタム UITextField クラスを作成する必要があります
そのための手順は次のとおりです。
Xcode では、[プロジェクト] -> [新しいファイル] -> [ユーザー インターフェイス] -> [空のビュー] -> [作成 (CustomUITextField)]
空のビューで -> UITextField を空のビューにします。
Xcode では、Project -> New File -> Cocoa Touch -> Next -> UITextField のサブクラスを選択 -> 名前を付ける (CustomTextField) -> Next
2 ファイルは .h と .m を作成します
.h そのように見える
輸入<UIKit/UIKit.h>
@interface CustomUITextField : UITextField{
}
@property(nonatomic, retain) UIImage *centerImage;
@end
.m そのようにファイルのように見えます
#import "CustomUITextField.h"
@implementation CustomUITextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
[self superclass];
// Drawing code
UIImageView *circle;
circle = [[UIImageView alloc] initWithFrame:CGRectMake(80, 5, 20, 20)];
circle.image = [UIImage imageNamed:@"Default.png"];
[self addSubview:circle];
}
@end