iOS 8.0 毛玻璃效果UIVisualEffect
2014-10-09 14:16
555 查看
随着iOS8.0和OS X 10.0的发布,大量的毛玻璃效果随处可见.
以前我们实现毛玻璃效果,更多是通过CGImage来实现.现在,XCode6中自带了实现这一效果的API.API如下:
@测试代码:
以前我们实现毛玻璃效果,更多是通过CGImage来实现.现在,XCode6中自带了实现这一效果的API.API如下:
typedef NS_ENUM(NSInteger, UIBlurEffectStyle) { UIBlurEffectStyleExtraLight, UIBlurEffectStyleLight, UIBlurEffectStyleDark } NS_ENUM_AVAILABLE_IOS(8_0); NS_CLASS_AVAILABLE_IOS(8_0) @interface UIVisualEffect : NSObject <NSCopying, NSSecureCoding> @end /* UIBlurEffect will provide a blur that appears to have been applied to the content layered behind the UIVisualEffectView. Views added to the contentView of a blur visual effect are not blurred themselves. */ NS_CLASS_AVAILABLE_IOS(8_0) @interface UIBlurEffect : UIVisualEffect + (UIBlurEffect *)effectWithStyle:(UIBlurEffectStyle)style; @end /* UIVibrancyEffect amplifies and adjusts the color of content layered behind the view, allowing content placed inside the contentView to become more vivid. It is intended to be placed over, or as a subview of, a UIVisualEffectView that has been configured with a UIBlurEffect. This effect only affects content added to the contentView. Because the vibrancy effect is color dependent, subviews added to the contentView need to be tintColorDidChange aware and must be prepared to update themselves accordingly. UIImageView will need its image to have a rendering mode of UIImageRenderingModeAlwaysTemplate to receive the proper effect. */ NS_CLASS_AVAILABLE_IOS(8_0) @interface UIVibrancyEffect : UIVisualEffect + (UIVibrancyEffect *)effectForBlurEffect:(UIBlurEffect *)blurEffect; @end NS_CLASS_AVAILABLE_IOS(8_0) @interface UIVisualEffectView : UIView <NSSecureCoding> @property (nonatomic, retain, readonly) UIView *contentView; // Do not add subviews directly to UIVisualEffectView, use this view instead. @property (nonatomic, copy, readonly) UIVisualEffect *effect; - (instancetype)initWithEffect:(UIVisualEffect *)effect NS_DESIGNATED_INITIALIZER; @end
@测试代码:
// 图片 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 100, 300, 400)]; [imageView setImage:[UIImage imageNamed:@"IMG_0015.JPG"]]; [self.view addSubview:imageView]; // blur效果 self.visualEfView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; _visualEfView.frame = CGRectMake(0, 0, 300, 400); _visualEfView.alpha = 1.0; [imageView addSubview:_visualEfView];@Demo运行效果:
相关文章推荐
- iOS 8.0 毛玻璃效果利用UIVisualEffectView快速实现
- iOS 8.0 毛玻璃效果UIVisualEffect
- IOS 高斯模糊 (毛玻璃效果 UIVisualEffect)
- iOS_8_API:UIVisualEffectView (毛玻璃效果)
- [IOS 开发] 使用UIVisualEffectView实现模糊效果
- iOS开发UIBlurEffect系统自带毛玻璃效果
- iOS开发之实现模糊效果 Core Image 、 vImage 、UIVisualEffectView、FXBlurView、GPUImage、UIImage+ImageEffects
- iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView
- iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView
- iOS毛玻璃效果
- iOS8 模糊视图(毛玻璃效果) UIVisualEffectView
- 【深入浅出IOS开发】彩票-去除图标的玻璃质感效果
- iOS毛玻璃效果的实现
- 【深入浅出IOS开发】彩票-去除图标的玻璃质感效果
- IOS的app图标去掉玻璃效果
- ios毛玻璃效果
- iOS8中用UIVisualEffectView实现高斯模糊视图(毛玻璃效果)
- IOS毛玻璃效果
- iOS:毛玻璃效果
- iOS 图片毛玻璃效果