IOS development and ios development tutorial

Source: Internet
Author: User

IOS development and ios development tutorial
Effect display

Objective-C code implementation
# Import "ViewController. h "@ interface ViewController () {// implement the fuzzy effect class uivisual1_tview * _ visual1_tview;} @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; [self initializeUserInterface];}-(void) initializeUserInterface {self. view. backgroundColor = [UIColor whiteColor]; // Add Image view UIImageView * imageView = [[UIImageView alloc] initWithFrame: self. view. frame]; imageView. image = [[UIImage imageNamed: @ "image.png"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]; imageView. contentMode = UIViewContentModeScaleAspectFit; imageView. userInteractionEnabled = YES; [self. view addSubview: imageView]; // slide bar UISlider * slider = [[UISlider alloc] initWithFrame: CGRectMake (10, CGRectGetMaxY (self. view. bounds)-50, CGRectGetWidth (self. view. bounds)-20, 30)]; slider. maximumValue = 1.0; slider. minimumValue = 0.0; slider. value = 1.0; [slider addTarget: self action: @ selector (respondsToSlider :) forControlEvents: UIControlEventValueChanged]; [self. view addSubview: slider]; // implement the fuzzy effect UIBlurEffect * blur = [invalid neural twithstyle: watermark]; _ visualiztview = [[uivisualiztview alloc] initWithEffect: blur]; _ visualiztview. frame = self. view. frame; _ visualiztview. alpha = 1.0; _ visualiztview. userInteractionEnabled = YES; [imageView addSubview: _ visualiztview];} # pragma mark-event methods-(void) respondsToSlider :( UISlider *) slider {_ visualiztview. alpha = slider. value;} @ end
Swfit code implementation
Import UIKitclass ViewController: UIViewController {var visualiztview: uivisualiztview? Override func viewDidLoad () {super. viewDidLoad () self. initializeUserInterface ()} func initializeUserInterface () {// Add Image view let imageView = UIImageView (frame: self. view. frame) imageView. image = UIImage (named: "image.png") self. view. addSubview (imageView) // Add slide bar let slider = UISlider (frame: CGRectMake (10, CGRectGetMaxY (self. view. bounds)-50, CGRectGetWidth (self. view. bounds)-20, 30) slider. ma XimumValue = 1.0 slider. minimumValue = 0.0 slider. value = 1.0 slider. addTarget (self, action: Selector ("respondsToSlider:"), forControlEvents: UIControlEvents. valueChanged) self. view. addSubview (slider) // implement the blur effect. let blur = UIBlurEffect (style: UIBlurEffectStyle. light) self. visualiztview = ({let visualiztview = uivisualiztview (effect: blur) visualiztview. frame = imageView. frame visualEff EctView. userInteractionEnabled = true visualiztview. tag = 100 visualiztview. alpha = 1.0 return visualiztview}) () imageView. addSubview (self. visualiztview !)} Func respondsToSlider (sender: UISlider) {self. visualizer tview ?. Alpha = CGFloat (sender. value )}}

Copyright Disclaimer: This article is the original article of the blogger. For more information, see the original article.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.