在按钮上应用阴影使按钮文本模糊
Applying shadow on uibutton Makes the button text blury
这是我在使用 .XIB 文件创建的 uibutton 上添加阴影的代码
UIBezierPath *shadowPathEndbtn = [UIBezierPath bezierPathWithRect:CGRectMake(0, self->_navigationView.frame.size.height - 70,[UIScreen mainScreen].bounds.size.width , 2)];
self->_EndButton.layer.masksToBounds = NO;
self->_EndButton.layer.shadowColor = [UIColor blackColor].CGColor;
self->_EndButton.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
self->_EndButton.layer.shadowOpacity = 0.7f;
self->_EndButton.layer.shouldRasterize = YES;
self->_EndButton.layer.shadowPath = shadowPathForEndbtn.CGPath;
我可以使用这段代码设置阴影,但这段代码使我的按钮文本看起来很模糊。我无法弄清楚这背后的确切原因。感谢任何帮助!
self->_EndButton.layer.masksToBounds = false
self->_EndButton.layer.shadowColor = [UIColor blackColor].CGColor
self->_EndButton.layer.contentsScale = [[UIScreen mainScreen]scale];
self->_EndButton.layer.shadowOpacity = 0.7f;
self->_EndButton.layer.shadowRadius = 10.0;
self->_EndButton.layer.shadowOffset = CGSizeMake(0,0)
这会产生阴影,而且测试不模糊
设置按钮背景颜色
self.EndButton.BackgroundColor=[UIColor WhiteColor];
这是我在使用 .XIB 文件创建的 uibutton 上添加阴影的代码
UIBezierPath *shadowPathEndbtn = [UIBezierPath bezierPathWithRect:CGRectMake(0, self->_navigationView.frame.size.height - 70,[UIScreen mainScreen].bounds.size.width , 2)];
self->_EndButton.layer.masksToBounds = NO;
self->_EndButton.layer.shadowColor = [UIColor blackColor].CGColor;
self->_EndButton.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
self->_EndButton.layer.shadowOpacity = 0.7f;
self->_EndButton.layer.shouldRasterize = YES;
self->_EndButton.layer.shadowPath = shadowPathForEndbtn.CGPath;
我可以使用这段代码设置阴影,但这段代码使我的按钮文本看起来很模糊。我无法弄清楚这背后的确切原因。感谢任何帮助!
self->_EndButton.layer.masksToBounds = false
self->_EndButton.layer.shadowColor = [UIColor blackColor].CGColor
self->_EndButton.layer.contentsScale = [[UIScreen mainScreen]scale];
self->_EndButton.layer.shadowOpacity = 0.7f;
self->_EndButton.layer.shadowRadius = 10.0;
self->_EndButton.layer.shadowOffset = CGSizeMake(0,0)
这会产生阴影,而且测试不模糊
设置按钮背景颜色
self.EndButton.BackgroundColor=[UIColor WhiteColor];