iOS:UIButton 标题阴影颜色不起作用

标签 ios objective-c uibutton

<分区>

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.titleLabel.shadowColor = [UIColor blackColor];
    btn.titleLabel.shadowOffset = CGSizeMake(1, 1);

当我在 ios7 上运行时,按钮根本没有阴影。提出你的建议。

最佳答案

首先将“QuartzCore”库添加到您的项目和#import <QuartzCore/QuartzCore.h>这是你的类(class),做这样的事情

 btn.titleLabel.layer.shadowColor = [UIColor blackColor].CGColor;//set preferred color
 btn.titleLabel.layer.shadowOpacity = 0.7;//set opacity 

关于iOS:UIButton 标题阴影颜色不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20649794/

相关文章:

ios - 从 Firebafirebase 崩溃报告 OLD 迁移到 Firebase/Crashlytics

ios - 如何在swift中实现平行 map

objective-c - Objective-C 中的移动平均线

iphone - iPhone将图像保存到文档目录

ios - 左右两侧的 UIButton 边框

设备旋转后的 iOS 按钮点击区域

ios - 圈复杂度违规 : Function should have complexity 10 or less: currently complexity equals 13 (cyclomatic_complexity)

objective-c - 为什么要检查静态变量是否为nil,然后再对其进行分配?

swift - 以编程方式按钮自动布局?

ios - 在 'levelCompleted' 类型的对象上找不到属性 'id'