Because the cursor color and tint color of the search bar are uniform, if you want to set the cursor color to a different color, you need to modify it inside the textfiled, and the same for the font.
Implementation code:
-(void) setsearchbartextfiled: (Uisearchbar *) searchbar{for (UIView *view in searchbar.subviews) {for (ID Subview in view.subviews) { if ([Subview Iskindofclass:[uitextfield class]) { [(Uitextfield *) Subview Settintcolor:[uicolor Graycolor]]; [(Uitextfield *) Subview Setfont:[uifont Fontwithname:general_font size:13]]; return;}}}
If you want to implement the user cannot enter into the search box, you need to textfiled the input invalidation:
One approach is to set the disable for the entire searchbar, but if there are other components, such as the scope button, it will also fail:
[Searchbar Setuserinteractionenabled:no];
Implementation code:
-(void) Enabletextinput: (Uisearchbar *) searchbar{for (UIView *view in searchbar.subviews) {for (ID subview in View.subviews) { if ([Subview Iskindofclass:[uitextfield class]]) { [Subview setenabled:yes]; return;}}} -(void) Disabletextinput: (Uisearchbar *) searchbar{for (UIView *view in searchbar.subviews) {for (ID subview in View.subviews) { if ([Subview Iskindofclass:[uitextfield class]]) { [Subview setenabled:no]; return;}}}
Reference Links:
Http://stackoverflow.com/questions/9968595/how-to-enable-cancel-button-with-uisearchbar
Http://stackoverflow.com/questions/11606007/change-uitextfield-and-uitextview-cursor-caret-color
Http://stackoverflow.com/questions/2190352/change-color-of-cursor-in-text-field
Http://stackoverflow.com/questions/9169049/disable-uisearchbar
IOS modifies the cursor cursor color and font style and size of the Searchbar textfiled; Disable input box