【问题标题】:How to achieve a vibrant selection state in a Notification Center Today Widget如何在今日通知中心小部件中实现充满活力的选择状态
【发布时间】:2014-11-24 21:35:05
【问题描述】:

我想实现一个选定的状态,其效果类似于内置小部件的效果,通知背后的颜色显示出来。我该怎么做?

【问题讨论】:

    标签: ios ios8-today-widget uivisualeffectview


    【解决方案1】:

    只需使用[UIVibrancyEffect notificationCenterVibrancyEffect]UIButton 添加到UIVisualEffectsView 的contentView:

    UIButton *myButton = ...
    self.effectsView = [[UIVisualEffectView alloc] initWithEffect:[UIVibrancyEffect notificationCenterVibrancyEffect]];
    self.effectsView.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.effectsView];
    
    [self.effectsView.contentView addSubview:myButton];
    

    默认情况下,按钮的 backgroundColor 应该是 [UIColor clearColor]。然后,当它被点击时,只需将其背景颜色设置为[[UIColor lightGrayColor] colorWithAlphaComponent:0.5]。 (当通知中心后面的内容几乎全是白色时,alpha 值会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多