The Navigation bar search box is a UI control that is often used for non-use.
1. Requirements:
- On the Discovery page, add a search box to the top navigation bar Navigationbar
- The left with the magnifying glass icon
2. Ideas
- Use Uisearchbar: Apple system comes with, simple and easy to use, but the style is inflexible can not be customized (here Uisearchbar background color is easy to confuse with the background color of the navigation bar), can not modify the width of the height, and the iOS6 and iOS7 will produce different styles.
- Create with Uitextfield: Inherit or extend Uitextfield, set background and left-side icons
3. Implement
- Create a custom class that inherits Uitextfield, which is named Uysearchbar
- Overrides the initWithFrame method, which is used to initialize the search box's icon, background picture, icon and text symmetry, clear button display
- Instantiate the Uysearchbar on the desired controller, assign its location dimension information, and add it to the Navigationitem Titleview
4. Set the search image to be stretched
iOS Sina Weibo-1.1 Navigation bar search box