ios - 将圆角和边框设置为 ios7 中 UISearchBar 的背景(不是 UITextField)

标签 ios objective-c ios7 uisearchbar

如何在 ios7 中为 UISearchBar 的背景应用圆角和边框?我可以更改栏的背景颜色。

像这样

enter image description here

谢谢

最佳答案

  UISearchBar *searchBar  = [[UISearchBar alloc] init];
  searchBar.layer.cornerRadius  = 6;
  searchBar.clipsToBounds       = YES;
  [searchBar.layer setBorderWidth:1.0];
  [searchBar.layer setBorderColor:[[UIColor lightGrayColor].CGColor];

关于ios - 将圆角和边框设置为 ios7 中 UISearchBar 的背景(不是 UITextField),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22807074/

相关文章:

ios - 什么时候使用 NSSet 而不是 NSArray 更好?

android - 基于 HTML 的手机应用程序在 Android 上比在 IOS 上更容易被接受?

ios - 应用程序崩溃: when writeVideoAtPathToSavedPhotosAlbum using ALAssetsLibrary

ios - 没有动画 UITableViewCell 选择

ios - Testflight 是否不再支持新版本的应用内通知?

ios - AVAssetExportSession 失败 - 合并 2 个 WAV 文件 (iOS7)

iphone - 替换弃用的 sizeWithFont :minFontSIze:actualFontSize in ios 7

ios - 在动画 UIView 上点击手势不起作用

iphone - 像通知栏一样在 iPhone 中拉起 View

ios - 无法识别的选择器 mutableCopyWithZone