在导航栏上放UISearchBar并且做圆角




UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 35)];
//allocate titleView
         UIColor *color =   self .navigationController.navigationBar.tintColor;
         [titleView setBackgroundColor:color];
         
         UISearchBar *searchBar = [[UISearchBar alloc] init];
         searchBar.delegate = self ;
         searchBar.frame = CGRectMake(0, 0, 150, 35);
         searchBar.backgroundColor = color;
         searchBar.layer.cornerRadius = 18;
         searchBar.layer.masksToBounds = YES ;
         [titleView addSubview:searchBar];
         
         //Set to titleView
         self .navigationItem.titleView = titleView;
片:屏幕快照 2014-01-17 下午2.30.12.png
在导航栏上放UISearchBar并且做圆角_第1张图片

你可能感兴趣的:(在导航栏上放UISearchBar并且做圆角)