内在发光的伊布顿



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

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

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

你可以

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

#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;

最新更新