ios_3_ Picture View

Source: Internet
Author: User

BeyondViewController.h

  beyondviewcontroller.h//  03_ Pictures Browse////  Created by Beyond on 14-7-22.//  Copyright (c) 2014 Com.beyond. All rights reserved.//#import <UIKit/UIKit.h> @interface Beyondviewcontroller: Uiviewcontroller@property (Weak, nonatomic) Iboutlet UILabel *pagenolabel; @property (weak, nonatomic) Iboutlet Uiimageview *pictureview; @property (weak, nonatomic) Iboutlet UILabel *descriptionlabel; @property (weak, nonatomic) Iboutlet UIView *viewsetting;-(ibaction) slidevaluechanged: (UISlider *) sender;-(ibaction) Setting: (UIButton *) sender ;//Switch Switch-(ibaction) Switchclick: (Uiswitch *) sender;//picture size scaling-(ibaction) sliderscalevaluechanged: (UISlider *) Sender; @end





Beyondviewcontroller.m

beyondviewcontroller.m//03_ Pictures Browse////Created by Beyond on 14-7-22.//Copyright (c) 2014 Com.beyond.    All rights reserved.//#import "BeyondViewController.h" @interface Beyondviewcontroller () {//load Mainbundle from plist, return array Nsarray *_descarray;}    @end @implementation beyondviewcontroller-(void) viewdidload{[Super Viewdidload]; Load plist from Mainbundle, return array, load once//Sg_bundle template code, 1, get. The main package of the app, 2, return the FullPath full path of a file in the main package nsbundle *mainbundle = [    NSBundle Mainbundle];    NSString *fullpath = [Mainbundle pathforresource:@ "Descs.plist" oftype:nil];    Member variables are remembered because _descarray = [Nsarray Arraywithcontentsoffile:fullpath] is used in other methods slidevaluechanged; _descriptionlabel.text = _descarray[0];}    -(Ibaction) slidevaluechanged: (UISlider *) Sender {NSLog (@ "%d", (int) sender.value);    The picture name is from 0 to 15, corresponding to the slide minimum value 0 max int pageno = (int) sender.value;    1, control picture display nsstring *imagename = [NSString stringwithformat:@ "%d.png", PageNo]; _pictureview.image = [UIImage imageNameD:imagename];    2, control title Display _pagenolabel.text = [nsstring stringwithformat:@ "%D/16", (pageno+1)]; 3, control description display plist in simulator full path///users/beyond/library/developer/xcode/deriveddata/03_ Picture Browse-cwowmkgqqqqmfcfxckpaqtzykyus/build/products/debug-iphonesimulator/03_ Picture Browse. App/descs.plist///Users/beyond/ Library/application support/iphone simulator/7.1/applications/02291f09-5446-40e2-82ae-18b6d039d88a/03_ pictures view. app/        Descs.plist//NSString *descplistfullpath = [[NSBundle mainbundle] pathforresource:@ "descs.plist" ofType:nil];    _descriptionlabel.text = [_descarray Objectatindex:pageno]; _descriptionlabel.text = _descarray[pageno];} #pragma mark-set: 1, Night mode;    2, Image Zoom-(ibaction) Setting: (UIButton *) Sender {//UIView class method implementation animation effect (start animation) [UIView Beginanimations:nil Context:nil];        The default animation duration is 0.2 [UIView setanimationduration:1];    int winheight = Self.view.bounds.size.height; CGFloat targety = _viewsetting.frame.origin.y==winheight? (Winheight-self.viewsetting.framE.size.height): Winheight;    The following three steps are the OC Standard Code, because OC does not allow the value of the member of the struct attribute in the object to be repaired directly, through the intermediate temporary structure body variable cgrect frame = Self.viewSetting.frame;    FRAME.ORIGIN.Y = targety;    Self.viewsetting.frame=frame; UIView class method for animating (ending animation) [UIView commitanimations];} -(Ibaction) Switchclick: (Uiswitch *) Sender {if (Sender.ison) {self.view.backgroundColor = [Uicolor darkgraycol    or];    } else {self.view.backgroundColor = [uicolor Whitecolor]; }}-(ibaction) sliderscalevaluechanged: (UISlider *) Sender {//UIView class method for animation effect (start animation) [UIView Beginanimations:nil Co    Ntext:nil];        The default animation duration is 0.2 [UIView setanimationduration:1];        Self.pictureView.transform = Cgaffinetransformmakescale (Sender.value, Sender.value); UIView class method for animating (ending animation) [UIView commitanimations];} @end














ios_3_ Picture View

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.