2012-05-30 74 views
0

我試圖將陰影應用於UILabel,但我在字體上看到了一個醜陋的上影。IOS 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"; 

enter image description here

+0

這是在模擬器上?模擬器不像手機使用Core Animation那樣繪製。另外,如果您發佈您的UIShadowLabel,我們可以查看代碼。它可能會增加一箇中風。 –

+0

不,我可以在設備上看到這個陰影。 –

回答

0

使用根據自己的需要

[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)];