2014-09-15 15 views
6

Chúng tôi đã tích hợp thành công UIVibrancyEffect và UIVisualEffectView vào ứng dụng của mình, nhưng tôi nhận thấy rằng độ rung không mạnh như tôi muốn và văn bản mờ hơn bản demo 'đã từng thấy. Tôi không thể tìm thấy bất kỳ cách nào để tinh chỉnh điều này, hoặc để ảnh hưởng đến nó trong bất kỳ cách nào. Tôi nghĩ rằng nó có thể là bởi vì chúng tôi đang sử dụng một phông chữ tùy chỉnh, nhưng tôi đã cố gắng đó quá và phông chữ dày hơn nhưng vẫn trông mờ. Bất kỳ ý tưởng?UIVibrancyEffect UIVisualEffectView subview không đủ sôi động

Với phông chữ tùy chỉnh Open Sans Light của chúng tôi:

screenshot of our custom font (open sans light)

Với hệ thống phông chữ:

screenshot with system font

Đây là mã:

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 
[blurEffectView setFrame:self.viewController.view.bounds]; 

UIVisualEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect]; 
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect]; 
[vibrancyEffectView setFrame:self.viewController.view.bounds]; 


[blurEffectView.contentView addSubview:vibrancyEffectView]; 


UITextView *messageText = [[UITextView alloc] initWithFrame:CGRectMake(0,0,320,568)]; 
[messageText setFont:[CLAppearanceManager fontForLabelType:CLAppearanceLabelFontWaveMessageEntry]]; 
[messageText setTextColor:[UIColor whiteColor]]; 
messageText.layer.shadowColor = [[UIColor blackColor] CGColor]; 
messageText.layer.shadowOffset = CGSizeMake(1.0,1.0); 
messageText.layer.shadowRadius = 3.0; 
[messageText setBackgroundColor:[UIColor clearColor]]; 
if(self.messageLabel.text && self.messageLabel.text.length>0) { 
    [messageText setText:self.messageLabel.text]; 
} else { 
    [messageText setText:@"no message"]; 
} 
[messageText setTextAlignment:NSTextAlignmentCenter]; 
[messageText setEditable:NO]; 
[messageText addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL]; 

self.bigMessageText = messageText; 
[vibrancyEffectView.contentView addSubview:messageText]; 
self.blurView = blurEffectView; 

UITapGestureRecognizer *dismiss = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeBlurView)]; 
[self.blurView addGestureRecognizer:dismiss]; 
[self.viewController.view addSubview:self.blurView]; 
[self.class centerContentForTextView:messageText]; 
[self.blurView setAlpha:0.0]; 

[UIView animateWithDuration:0.2 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
    [self.blurView setAlpha:1.0]; 
} completion:nil 
}]; 
+2

Vui lòng xem chi tiết hơn về cách bạn thiết lập phân cấp chế độ xem, đặc biệt là chế độ xem hiệu ứng mờ và chế độ xem hiệu ứng rung. –

Trả lời

2

Mặc dù documentation suggests bạn sử dụng cùng UIVisualEffect như UIVisualEffectView:

Khi bạn tạo ra một hiệu ứng rung động mới, sử dụng UIBlurEffect tương tự mà bạn sử dụng để tạo cái nhìn mờ. Sử dụng UIBlurEffect khác có thể gây ra các kết hợp hiệu ứng hình ảnh không mong muốn.

tôi sẽ khuyên bạn nên thiết của bạn UIVibrancyEffect-UIBlurEffectStyleLight:

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 
[blurEffectView setFrame:self.viewController.view.bounds]; 

UIBlurEffect *vibrancyBlurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 
UIVisualEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:vibrancyBlurEffect]; 
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect]; 
[vibrancyEffectView setFrame:self.viewController.view.bounds]; 
[blurEffectView.contentView addSubview:vibrancyEffectView]; 
0

Thêm Chính xác cùng Label/TextView để vibrancyEffectView (không contentView)

Các Label/TextView nên có một alpha ít hơn 1,0. Tôi giữ nó 0,5. Bạn có thể thử bất kỳ giá trị nào khác.

Các vấn đề liên quan