ios7 修改searchbar 取消 字体 颜色

本文详细介绍了如何在iOS应用中修改UIButton的样式,包括设置标题、颜色和字体,并且展示了如何调整searchBar的颜色,提供了代码示例。
    UIButton *cancelButton;
    UIView *topView = self.searchDisplayController.searchBar.subviews[0];
    for (UIView *subView in topView.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
            cancelButton = (UIButton*)subView;
        }
    }
    if (cancelButton) {
        //Set the new title of the cancel button
        [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        [cancelButton setTitleColor:[UIColor colorWithRed:53.f/255.f green:114.f/255.f blue:255.f/255.f alpha:1.0] forState:UIControlStateNormal];
        cancelButton.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:15];
    }



原来还有个方法 

self.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:53.f/255.f green:114.f/255.f blue:255.f/255.f alpha:1.0];

效果图


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值