Nonsense not to say more, directly to everyone to paste the key code, the specific code as follows:
#import <UIKit/UIKit.h> @interface Searchbar:uitextfield @property (nonatomic,strong) UIButton *button;
+ (instancetype) Searchbar; @end #import "SearchBar.h" @implementation Searchbar-(ID) initWithFrame: (CGRect) frame {self = [super Initwithframe:fram
E]; if (self) {self.font = [Uifont systemfontofsize:15]; self.placeholder = @ "Enter breed keyword";//set Border and border color SELF.BORDERSTYLE=UITEXTB
Orderstylenone;
self.layer.cornerradius=15.0f;
Self.layer.maskstobounds=yes;
Self.layer.bordercolor=[[uicolor colorwithred:224/255.0 green:243/255.0 blue:223/255.0 Alpha:1.0]CGColor];
Self.layer.borderwidth= 2.0f;
UIButton *button = [[UIButton alloc] Initwithframe:cgrectmake (0, 0, 40, 30)];
[Button setbackgroundimage:[uiimage imagenamed:@ "Seachbar_rightview"] forstate:uicontrolstatenormal];
[Button settitle:@ "search" forstate:uicontrolstatenormal]; [Button Settitlecolor:[uicolor colorwithred:119/255.0 green:166/255.0 blue:16/255.0 alpha:1.0] ForState:
UIControlStateNormal]; Button.titleLabel.font = [Uifont Systemfontofsize:18.0];
Button.titleLabel.textColor = [Uicolor colorwithred:119/255.0 green:166/255.0 blue:16/255.0 alpha:1.0];
Button.titleLabel.textColor = [Uicolor Redcolor];
Self.rightview = button;
Self.rightviewmode = Uitextfieldviewmodealways;
This sets the cursor position so that the cursor position is moved after ten self.leftview = [[UIView alloc]initwithframe:cgrectmake (0, 0, 10, 0)];
Self.leftviewmode = Uitextfieldviewmodealways;
return self; } + (Instancetype) Searchbar {return [[Self alloc] init];}
Below is a description of the cursor position of the setting input box in iOS
This sets the cursor position so that the cursor position is moved after ten
textfield.leftview = [[UIView alloc]initwithframe:cgrectmake (0, 0, 0)];
Textfield.leftviewmode = Uitextfieldviewmodealways;
The above is a small set to introduce the iOS searchbar (search box) cursor initial position after the move, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!