UIButton Header Does Not Display When Applying UIVibrancyEffect

I'm having trouble using UIVibrancyEffect for my UIButtons in iOS widgets today. I want them to like the default “Change” button in the notification center. Today section:

Widget today

As you can see in the screenshot, the default button is bright and looks much better.

I tried replacing the widget Viewwith the UIVisualEffectViewfollowing:

UIVisualEffectView effectView = new UIVisualEffectView(UIVibrancyEffect.CreateForNotificationCenter ());
effectView.Frame = this.View.Bounds;
effectView.AutoresizingMask = this.View.AutoresizingMask;
UIView oldView = this.View;
this.View = effectView;
effectView.ContentView.AddSubview(oldView);
this.View.TintColor = UIColor.Clear;

And it seems to work, but the names of my buttons also become bright (I want them to remain black):

enter image description here

Is there a way to prevent button shortcuts from appearing when using UIVibrancyEffect? A.

I should also add that I am using Xamarin.iOS.

+4
1

, . UIVisualEffectView UIView UIButton.

, :

// Create effect view
var effectView = new UIVisualEffectView(UIVibrancyEffect.CreateForNotificationCenter ());
// This color looks best for me. You can play around with it to make it look better
effectView.BackgroundColor = UIColor.FromRGBA(55, 55, 55, 100);
// Position effectView
effectView.Frame = myButton.Frame;
// Add effectView and send it to back, behind actual button
this.View.AddSubview(effectView);
this.View.SendSubviewToBack (effectView);

// Create UIView and add it to effectView ContentView
var view = new UIView ();
view.BackgroundColor = UIColor.White;
effectView.ContentView.AddSubview(view);
view.Frame = new CGRect(0, 0, effectView.Frame.Width, effectView.Frame.Height);

// Make sure your effect view has rounded corners
effectView.Layer.MasksToBounds = true;
effectView.Layer.CornerRadius = 4.0f;

:

enter image description here

+1

Source: https://habr.com/ru/post/1620589/


All Articles