- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIPinchGestureRecognizer *pinchGuesture = [[UIPinchGestureRecognizer alloc] initWithTarget: self action: @selector(pinGuestureHandle:)]; [[self view] addGestureRecognizer:pinchGuesture]; } -(void) pinGuestureHandle:(UIPinchGestureRecognizer *) sender { NSLog(@"Pin Gesture Handling"); }
// // ViewController.h // pinchGesture // // Created by Weerachai on 11/17/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UILabel *lblString; } @end
// // ViewController.m // pinchGesture // // Created by Weerachai on 11/17/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIPinchGestureRecognizer *pinchGuesture = [[UIPinchGestureRecognizer alloc] initWithTarget: self action: @selector(pinGuestureHandle:)]; [[self view] addGestureRecognizer:pinchGuesture]; } -(void) pinGuestureHandle:(UIPinchGestureRecognizer *) sender { NSLog(@"Pin Gesture Handling"); UIFont *font = lblString.font; CGFloat pointSize = font.pointSize; NSString *name = font.fontName; pointSize = ((sender.velocity > 0) ? 1 : -1) * 1 + pointSize; if (pointSize < 14) pointSize = 14; if (pointSize > 38) pointSize = 38; lblString.font = [UIFont fontWithName:name size:pointSize]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [lblString release]; [super dealloc]; } @end
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท