0

我想创建一个带有内发光的矩形圆角按钮。我听到一些关于添加子视图的建议,但我担心子视图会覆盖我按钮中的文本。

如何在不遮挡文本或背景图标图像的情况下实现内部发光?

4

2 回答 2

0

制作您想要的图像,然后将其导入您的项目。将按钮的类型设置为自定义,然后将图像设置为您制作的发光图像。

于 2012-06-01T19:46:12.730 回答
0

您可以这样做(它不完全是按钮上的发光,而是按钮标签上的发光)。效果非常相似。第一的

#import <QuartzCore/QuartzCore.h>

进而

UIColor *color = button.currentTitleColor;
theButton.titleLabel.layer.shadowColor = [color CGColor];
theButton.titleLabel.layer.shadowRadius = 4.0f;
theButton.titleLabel.layer.shadowOpacity = .9;
theButton.titleLabel.layer.shadowOffset = CGSizeZero;
theButton.titleLabel.layer.masksToBounds = NO;
于 2012-06-01T19:51:59.013 回答