美文网首页iOS劝退指南
修改UISearchBar上的TextField高度

修改UISearchBar上的TextField高度

作者: MccReeee | 来源:发表于2016-11-18 15:57 被阅读341次
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x,self.searchController.searchBar.frame.origin.y,self.searchController.searchBar.frame.size.width,60);
//
//  MySearchBar.m
//  WingsBurning
//
//  Created by MBP on 16/9/1.
//  Copyright © 2016年 leqi. All rights reserved.
//

#import "MySearchBar.h"
#define screenWidth [UIScreen mainScreen].bounds.size.width

@implementation MySearchBar

-(void) layoutSubviews{
    [super layoutSubviews];
    UIView *searchTextField = nil;
    // 经测试, 需要设置barTintColor后, 才能拿到UISearchBarTextField对象
    self.barTintColor = [UIColor whiteColor];
    searchTextField = [[[self.subviews firstObject] subviews] lastObject];
    if([searchTextField isKindOfClass:[UITextField class]]){
        searchTextField.frame = CGRectMake(18, 10, screenWidth - 36, 44);
    }
}

///>>>>>>>>>>此处注释打开,SearchBar上的取消按钮就隐藏了<<<<<<<<<<<<*
-(void)setShowsCancelButton:(BOOL)showsCancelButton {

}

-(void)setShowsCancelButton:(BOOL)showsCancelButton animated:(BOOL)animated {
    
}

@end

相关文章

网友评论

    本文标题:修改UISearchBar上的TextField高度

    本文链接:https://www.haomeiwen.com/subject/rgfspttx.html