Difference between revisions of "UIBackdropView"

From iPhone Development Wiki
Jump to: navigation, search
m (Applying blur settings/style: Corrected data types.)
(Available settings classes (styles): Proper table.)
Line 25: Line 25:
 
Here's a list with known settings classes (subclasses of _UIBackdropViewSettings) available.
 
Here's a list with known settings classes (subclasses of _UIBackdropViewSettings) available.
  
<source lang="objc">
+
{| class="wikitable"
 
+
! Class !! Styles !! Applications !! Comments
_UIBackdropViewSettingsCombiner
+
|-
style: 3
+
| _UIBackdropViewSettingsCombiner
 
+
| 3
_UIBackdropViewSettingsNone
+
|
style: -2
+
|
 
+
|-
_UIBackdropViewSettingsLight
+
| _UIBackdropViewSettingsNone
style: 0, 1000, 1003, 2020, 10090, 10100
+
| -2
 
+
|
_UIBackdropViewSettingsDark
+
|
style: 0, 1001, 1100, 2030, 11050, 11060
+
|-
application: Notification Center, Keyboard (Dark), Safari Navigation Bar (Private mode)
+
| _UIBackdropViewSettingsLight
 
+
| 0, 1000, 1003, 2020, 10090, 10100
_UIBackdropViewSettingsBlur
+
|
style: 2
+
|
application: Common blurring
+
|-
 
+
| _UIBackdropViewSettingsDark
_UIBackdropViewSettingsColorSample
+
| 0, 1001, 1100, 2030, 11050, 11060
style: 2000
+
|
 
+
* Notification Center
_UIBackdropViewSettingsUltraLight
+
* Keyboard (Dark)
style (iOS 7): 2010
+
* Safari Navigation Bar (Private mode)
style (iOS 8+): 2010, 10050, 10060, 10070, 10080, 10110
+
|
application: Alert views and various UI (White)
+
|-
comment: fallback of unsupported styles
+
| _UIBackdropViewSettingsBlur
 
+
| 2
_UIBackdropViewSettingsLightLow
+
| Common blurring
style: 2029
+
|
comment: Optimized version of _UIBackdropViewSettingsLight
+
|-
 
+
| _UIBackdropViewSettingsColorSample
_UIBackdropViewSettingsDarkWithZoom
+
| 2000
style: 2031
+
|
 
+
|
_UIBackdropViewSettingsDarkLow
+
|-
style: 2039
+
| _UIBackdropViewSettingsUltraLight
comment: Optimized version of _UIBackdropViewSettingsDark
+
| (iOS 7) 2010
 
+
(iOS 8) 2010, 10050, 10060, 10070, 10080, 10110
_UIBackdropViewSettingsColored
+
| Alert views and various UI (White)
style: 2040
+
| Fallback of unsupported styles
Tint: rgba(0.0196078, 0.0196078, 0.0196078, 1)
+
|-
style: 10091
+
| _UIBackdropViewSettingsLightLow
Tint (iOS 7): rgba(0.160784, 1, 0.301961, 1)
+
| 2029
Tint (iOS 8): rgba(0.160784, 1, 0, 1)
+
|
Tint (iOS 9+): rgba(0.160784, 1, 0.301961, 1)
+
| Optimized version of _UIBackdropViewSettingsLight
style: 10092
+
|-
Tint (iOS 7): rgba(1, 0.0980392, 0.0470588, 1)
+
| _UIBackdropViewSettingsDarkWithZoom
Tint (iOS 8): rgba(1, 0.098039, 0.047059, 1)
+
| 2031
Tint (iOS 9+): rgba(1, 0.0980392, 0.0470588, 1)
+
|
style: 10120
+
|
Tint (iOS 7): rgba(0.0313725, 0.262745, 0.560784, 1)
+
|-
Tint (iOS 8): rgba(0.031373, 0.262745, 0.560784, 1)
+
| _UIBackdropViewSettingsDarkLow
Tint (iOS 9+): rgba(0.0313725, 0.262745, 0.560784, 1)
+
| 2039
 
+
|
_UIBackdropViewSettingsUltraDark
+
| Optimized version of _UIBackdropViewSettingsDark
style: 2050, 11070
+
|-
 
+
| rowspan="10" | _UIBackdropViewSettingsColored
_UIBackdropViewSettingsAdaptiveLight
+
| 2040
style: 2060
+
|
application: Control Center
+
| Tint: rgba(0.0196078, 0.0196078, 0.0196078, 1)
 
+
|-
_UIBackdropViewSettingsSemiLight
+
| rowspan="3" | 10091
style: 2070
+
| rowspan="3" |
 
+
| Tint (iOS 7): rgba(0.160784, 1, 0.301961, 1)
_UIBackdropViewSettingsFlatSemiLight
+
|-
style: 2071
+
| Tint (iOS 8): rgba(0.160784, 1, 0, 1)
 
+
|-
_UIBackdropViewSettingsUltraColored
+
| Tint (iOS 9+): rgba(0.160784, 1, 0.301961, 1)
style: 2080
+
|-
 
+
| rowspan="3" | 10092
=== iOS 7.1+ ===
+
| rowspan="3" |
 
+
| Tint (iOS 7): rgba(1, 0.0980392, 0.0470588, 1)
_UIBackdropViewSettingsPasscodePaddle
+
|-
style: 3900
+
| Tint (iOS 8): rgba(1, 0.098039, 0.047059, 1)
 
+
|-
_UIBackdropViewSettingsLightKeyboard
+
| Tint (iOS 9+): rgba(1, 0.0980392, 0.0470588, 1)
style: 3901
+
|-
 
+
| rowspan="3" | 10120
=== iOS 9.0+ ===
+
| rowspan="3" |
 
+
| Tint (iOS 7): rgba(0.0313725, 0.262745, 0.560784, 1)
_UIBackdropViewSettingsLightEmojiKeyboard
+
|-
style: 3902
+
| Tint (iOS 8): rgba(0.031373, 0.262745, 0.560784, 1)
 
+
|-
_UIBackdropViewSettingsATVSemiLight
+
| Tint (iOS 9+): rgba(0.0313725, 0.262745, 0.560784, 1)
style: 4000
+
|-
 
+
| _UIBackdropViewSettingsUltraDark
_UIBackdropViewSettingsATVMediumLight
+
| 2050, 11070
style: 4001
+
|
 
+
|
_UIBackdropViewSettingsATVLight
+
|-
style: 4002
+
| _UIBackdropViewSettingsAdaptiveLight
 
+
| 2060
_UIBackdropViewSettingsATVUltraLight
+
| Control Center
style: 4003
+
|
 
+
|-
_UIBackdropViewSettingsATVMenuLight
+
| _UIBackdropViewSettingsSemiLight
style: 4004
+
| 2070
 
+
|
_UIBackdropViewSettingsATVSemiDark
+
|
style: 4005
+
|-
 
+
| _UIBackdropViewSettingsFlatSemiLight
_UIBackdropViewSettingsATVMediumDark
+
| 2071
style: 4006
+
|
 
+
|
_UIBackdropViewSettingsATVDark
+
|-
style: 4007
+
| _UIBackdropViewSettingsUltraColored
 
+
| 2080
_UIBackdropViewSettingsATVUltraDark
+
|
style: 4008
+
|
 
+
|-
_UIBackdropViewSettingsATVMenuDark
+
| _UIBackdropViewSettingsPasscodePaddle
style: 4009
+
| 3900
 
+
|
_UIBackdropViewSettingsATVAdaptive
+
| iOS 7.1+
style: 4010
+
|-
 
+
| _UIBackdropViewSettingsLightKeyboard
_UIBackdropViewSettingsATVAdaptiveLighten
+
| 3901
style: 4011
+
|
 
+
| iOS 7.1+
_UIBackdropViewSettingsATVAccessoryLighten
+
|-
style: 4012
+
| _UIBackdropViewSettingsLightEmojiKeyboard
 
+
| 3902
=== iOS 9.3+ ===
+
|
 
+
| iOS 9.0+
_UIBackdropViewSettingsATVAccessoryDark
+
|-
style: 4013
+
| _UIBackdropViewSettingsATVSemiLight
 
+
| 4000
</source>
+
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVMediumLight
 +
| 4001
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVLight
 +
| 4002
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVUltraLight
 +
| 4003
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVMenuLight
 +
| 4004
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVSemiDark
 +
| 4005
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVMediumDark
 +
| 4006
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVDark
 +
| 4007
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVUltraDark
 +
| 4008
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVMenuDark
 +
| 4009
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVAdaptive
 +
| 4010
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVAdaptiveLighten
 +
| 4011
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVAccessoryLighten
 +
| 4012
 +
|
 +
| iOS 9.0+
 +
|-
 +
| _UIBackdropViewSettingsATVAccessoryDark
 +
| 4013
 +
|
 +
| iOS 9.3+
 +
|}
  
 
== Creating Sample ==
 
== Creating Sample ==

Revision as of 05:17, 12 August 2017

_UIBackdropView is a private class in UIKit.framework (iOS 7.0+), a subclass of UIView, which is used for the popular blur effects.

It uses a CABackdropLayer with a gaussianBlur CAFilter (kCAFilterGaussianBlur) .[1]

Creating Settings

_UIBackdropView uses a _UIBackdropViewSettings object for its setup. There are many ways to create it:

_UIBackdropViewSettings *settings = (_UIBackdropViewSettings *)[[[_UIBackdropViewSettingsSemiLight alloc] init] autorelease];

_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForStyle:2070];

_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForPrivateStyle:2070]; //this only calls settingsForStyle internally, so there are no advantages of using it over settingsForStyle 

_UIBackdropViewSettings *settings = [[[_UIBackdropViewSettings alloc] initWithDefaultsValue] autorelease];

_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForStyle:2030 graphicsQuality:100] ; //can be either 10 or 100, 100 is better. See notes at the bottom

Available settings classes (styles)

Here's a list with known settings classes (subclasses of _UIBackdropViewSettings) available.

Class Styles Applications Comments
_UIBackdropViewSettingsCombiner 3
_UIBackdropViewSettingsNone -2
_UIBackdropViewSettingsLight 0, 1000, 1003, 2020, 10090, 10100
_UIBackdropViewSettingsDark 0, 1001, 1100, 2030, 11050, 11060
  • Notification Center
  • Keyboard (Dark)
  • Safari Navigation Bar (Private mode)
_UIBackdropViewSettingsBlur 2 Common blurring
_UIBackdropViewSettingsColorSample 2000
_UIBackdropViewSettingsUltraLight (iOS 7) 2010

(iOS 8) 2010, 10050, 10060, 10070, 10080, 10110

Alert views and various UI (White) Fallback of unsupported styles
_UIBackdropViewSettingsLightLow 2029 Optimized version of _UIBackdropViewSettingsLight
_UIBackdropViewSettingsDarkWithZoom 2031
_UIBackdropViewSettingsDarkLow 2039 Optimized version of _UIBackdropViewSettingsDark
_UIBackdropViewSettingsColored 2040 Tint: rgba(0.0196078, 0.0196078, 0.0196078, 1)
10091 Tint (iOS 7): rgba(0.160784, 1, 0.301961, 1)
Tint (iOS 8): rgba(0.160784, 1, 0, 1)
Tint (iOS 9+): rgba(0.160784, 1, 0.301961, 1)
10092 Tint (iOS 7): rgba(1, 0.0980392, 0.0470588, 1)
Tint (iOS 8): rgba(1, 0.098039, 0.047059, 1)
Tint (iOS 9+): rgba(1, 0.0980392, 0.0470588, 1)
10120 Tint (iOS 7): rgba(0.0313725, 0.262745, 0.560784, 1)
Tint (iOS 8): rgba(0.031373, 0.262745, 0.560784, 1)
Tint (iOS 9+): rgba(0.0313725, 0.262745, 0.560784, 1)
_UIBackdropViewSettingsUltraDark 2050, 11070
_UIBackdropViewSettingsAdaptiveLight 2060 Control Center
_UIBackdropViewSettingsSemiLight 2070
_UIBackdropViewSettingsFlatSemiLight 2071
_UIBackdropViewSettingsUltraColored 2080
_UIBackdropViewSettingsPasscodePaddle 3900 iOS 7.1+
_UIBackdropViewSettingsLightKeyboard 3901 iOS 7.1+
_UIBackdropViewSettingsLightEmojiKeyboard 3902 iOS 9.0+
_UIBackdropViewSettingsATVSemiLight 4000 iOS 9.0+
_UIBackdropViewSettingsATVMediumLight 4001 iOS 9.0+
_UIBackdropViewSettingsATVLight 4002 iOS 9.0+
_UIBackdropViewSettingsATVUltraLight 4003 iOS 9.0+
_UIBackdropViewSettingsATVMenuLight 4004 iOS 9.0+
_UIBackdropViewSettingsATVSemiDark 4005 iOS 9.0+
_UIBackdropViewSettingsATVMediumDark 4006 iOS 9.0+
_UIBackdropViewSettingsATVDark 4007 iOS 9.0+
_UIBackdropViewSettingsATVUltraDark 4008 iOS 9.0+
_UIBackdropViewSettingsATVMenuDark 4009 iOS 9.0+
_UIBackdropViewSettingsATVAdaptive 4010 iOS 9.0+
_UIBackdropViewSettingsATVAdaptiveLighten 4011 iOS 9.0+
_UIBackdropViewSettingsATVAccessoryLighten 4012 iOS 9.0+
_UIBackdropViewSettingsATVAccessoryDark 4013 iOS 9.3+

Creating Sample

// Creating blur view using settings object
_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForStyle:2060];

// initialization of the blur view
_UIBackdropView *blurView = [[_UIBackdropView alloc] initWithFrame:CGRectZero
                                              autosizesToFitSuperview:YES settings:settings];
// another way for initialization
_UIBackdropView *blurView = [[_UIBackdropView alloc] initWithSettings:settings];

// or without settings object implementation
_UIBackdropView *blurView = [[_UIBackdropView alloc] initWithStyle:2060];

[someView addSubview:blurView];
[blurView release];

About _UIBackdropViewSettingsColored

You can give it a tint color (in fact, it already has a default tint color, and some styles (10091, 10092, 10120) set their own). Example:

_UIBackdropViewSettings *settings = [[_UIBackdropViewSettingsColored alloc]init];
[settings setTintColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:1];
//now use it somewhere

For iOS 9

_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForPrivateStyle:2040];
[settings setColorTint:[UIColor colorWithRed:1 green:0 blue:0 alpha:1]];
//now use it somewhere

Blurring Sample

There are only two blur qualities available.

  • low
  • default (Assumed to be "medium")

They correspend to the kCAFilterGaussianBlur's property "inputQuality"

[blurView setBlurRadiusSetOnce:NO];
[blurView setBlurRadius:10.0];
[blurView setBlurHardEdges:3];
[blurView setBlurWithHardEdges:YES];
[blurView setBlurQuality:@"low"];

Tinting Sample

[blurView setRequiresColorStatistics:YES];
[blurView setUsesColorTintView:YES];
UIColor *color = [UIColor cyanColor];
[blurView setColorTint:color]; // or you may use - (void)transitionToColor:(UIColor *)color;
[blurView setColorTintAlpha:0.8];
[blurView setColorTintMaskAlpha:0.7];

About graphics quality

Some styles require higher graphics quality, determined using [UIDevice _graphicsQuality] and might not be suitable for legacy devices. There are two values: 10 and 100. 100 looks better, but needs more resources. On default, iPad2,6, iPad2,7, iPad3,4, iPad3,5, iPad3,6, iPhone4,1, iPhone5,1, iPhone5,2, iPod5,1 get 10, the other devices get 100 (as of iOS 8.1). To manually set a graphic quality to a style, use

[_UIBackdropViewSettings settingsForStyle:2030 graphicsQuality:100]; // request style 2030 at highest graphics quality (100)
[_UIBackdropViewSettings settingsForStyle:2030 graphicsQuality:10]; // request style 2030 at lower graphics quality (10)

Applying blur settings/style

There are several ways for doing this by methods.

Signature - (void)transitionIncrementallyToPrivateStyle:(NSInteger)style weighting:(CGFloat)weight;
Available in 7.0 –
Signature - (void)transitionIncrementallyToStyle:(NSInteger)style weighting:(CGFloat)weight;
Available in 7.0 –
Signature - (void)transitionToSettings:(_UIBackdropViewSettings *)settings;
Available in 7.0 –
Signature - (void)transitionToPrivateStyle:(NSInteger)style;
Available in 7.0 –
Signature - (void)transitionToStyle:(NSInteger)style;
Available in 7.0 –

transitionIncrementallyToPrivateStyle and transitionIncrementallyToStyle do the same (transitionIncrementallyToPrivateStyle calls transitionIncrementallyToStyle internally). transitionToSettings and transitionToPrivateStyle are equivalent too.

For example

_UIBackdropViewSettings *newSettings = [_UIBackdropViewSettings settingsForPrivateStyle:0];

// Whatever configuration for the settings

blurView.inputSettings = newSettings;

Getting/Parsing all _UIBackdropView objects at runtime

NSArray *blurViews = [_UIBackdropView allBackdropViews];

for (_UIBackdropView *view in blurViews) {
      NSLog(@"This _UIBackdropView style is: %d", view.style);
     // do any _UIBackdropView configuration here
}

References