【问题标题】:IOS UILabel shadow generates weird upper shadowIOS UILabel 阴影生成奇怪的上阴影
【发布时间】:2012-05-30 15:44:48
【问题描述】:

我正在尝试对 UILabel 应用阴影,但我在字体上得到了一个难看的上阴影。

正如你所看到的,阴影已经远离字体,但我得到了这个有阴影的上部……字体应该是纯白色的。

有什么想法吗?我可以在上面放另一个 UILabel,但我认为这不是最干净的解决方案......

float width = 500.0f;
    UIShadowLabel *label = [[UIShadowLabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width * 0.5) - (width * 0.5), 150.0, width, 100.0) ];
    label.backgroundColor = [UIColor clearColor]; 
    label.shadowColor = UIColorFromRGB(0xb1b0b0);
    label.shadowRadius = 3.0f;
    label.shadowOffset = CGSizeMake(15.0f, 15.0f);
    label.textAlignment =  UITextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont fontWithName:@"Arial" size:(100.0)];
    [self.view addSubview:label];
    label.text = @"am";

【问题讨论】:

  • 这是在模拟器中吗?模拟器的绘制效果不如使用 Core Animation 的手机。此外,如果您发布您的 UIShadowLabel,我们可以查看代码。有可能是在添加笔画。
  • 不,我也可以在设备上看到这个影子。

标签: ios fonts uilabel shadow


【解决方案1】:

根据需要使用以下代码

[self.yourView.layer setShadowColor:[UIColor blackColor].CGColor];
[self.yourView.layer setShadowOpacity:0.8];
[self.yourView.layer setShadowRadius:3.0];
[self.yourView.layer setShadowOffset:CGSizeMake(2.0, 2.0)];

【讨论】:

    猜你喜欢
    • 2016-05-09
    • 1970-01-01
    • 2021-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    • 2021-02-19
    • 1970-01-01
    相关资源
    最近更新 更多