Many partners always think that the time to zoom picture is very troublesome, because do not know where to start, especially in the face of the new development language, in fact, there are many methods of image scaling, but original aim, that is frame, so, do not think so tall on. Here is an image scaling demousing masks, and interested partners can look at them.
//
Viewcontroller.swift
// Zoom of picture
//
Created by Yue technology on 15/1/15.
Copyright (c) year BSY. All rights reserved.
//
Import UIKit
Class Viewcontroller:uiviewcontroller {
var ImageView = Uiimageview ()
var button = UIButton ()
Override Func Viewdidload () {
Super.viewdidload ()
Initialize Uiimageview
var Imageview:uiimageview = Uiimageview (frame:cgrectmake (100, 100, 100, 100))
var image = UIImage (named: "1024")
Imageview.image = Image
Self.view.addSubview (ImageView)
Self.imageview = ImageView
Initialize UIButton(mask)
var Button:uibutton = Uibutton.buttonwithtype (uibuttontype.custom) as UIButton
var frame = Imageview.frame
Button.frame = Frame
Self.view.addSubview (Button)
Button.addtarget (Self, Action: "Changeimage:", ForControlEvents:UIControlEvents.TouchUpInside)
Self.button = button
Self.button.selected = False
}
initialization of the UIButton method implementation
Func Changeimage (Sender:uibutton) {
[UIView beginanimations ("", Context:nil)];
[UIView. Setanimationdelay (0.1)];
[UIView. Setanimationduration (0.5)];
self.button.selected =!sender.selected
if (self.button.selected = = True) {
Self.imageview.frame = Uiscreen.mainscreen (). Bounds
}else if (self.button.selected = = False) {
Self.imageview.frame = CGRectMake (100, 100, 100, 100)
[Uiview.commitanimations];}}
}
Swift developed UIButton as a mask for image scaling