iphone - 如何创建一个有光泽的渐变 UIButton

标签 iphone ios objective-c ipad uibutton

创建这样一个按钮而无需使用 .png 并将其设置为背景的最简单方法是什么?

enter image description here

最佳答案

 CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = self.rem.bounds;

    gradient.cornerRadius=7.0f;

    gradient.colors = [NSArray arrayWithObjects:
                       (id)[[UIColor blueColor] CGColor],
                       (id)[[UIColor blueColor] CGColor], (id)[[UIColor whiteColor] CGColor],nil];
    gradient.opacity=0.7f;

    [self.rem.layer insertSublayer:gradient atIndex:0];
    self.rem.layer.cornerRadius=7.0f;
    [self.rem.layer setBorderWidth:0.50f];

试试这个并导入QuartzCore

rem是UIButton的导出

我希望这能解决你的问题

关于iphone - 如何创建一个有光泽的渐变 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15831312/

相关文章:

iPhone:在 UIView 之上分层透明 openGL View ?

ios - sleep 周期 - 这是哪种后台模式?

ios - MKMapView 的黑白叠加层

ios - 以编程方式使用日期选择器更改按钮标题时,它始终会重置

ios - 动态添加气泡 View

iphone - iOS 6.0 Storyboard : Set static cell selected

iOS 辅助功能隐藏 "textField, double tap to edit"公告

ios - UITableView 更新后的 ReloadData

ios - objective-c 在用户调用电话时静音UILocalNotification

objective-c - 在数组中搜索 NSRange 的字符串