ios Help Screen semi-transparent overlay - objective-c

Wondering if anyone can shed some light on how to create a semi-transparent Help screen on an ipad or iphone app? Something similar to Googles app.
I have a splitViewController and I want to overlay a see-through black overlay on top of the splitViewController where I can show Help information about each item you can click in the splitViewController.
I followed http://cocoawithlove.com/2009/04/showing-message-over-iphone-keyboard.html which gets me the overlay, but I am now adding clickable UIViews (eg a close button to dismiss the overlay). The issue is when I setup touchesEnded:withEvent I cannot seem to convert clicks from the main LoadingView to closeButton to see what was actually clicked?
See the touches ended at the end of the code
================================================================
#import "HelpView.h"
#import <QuartzCore/QuartzCore.h>
//
CGPathRef NewPathWithRoundRect(CGRect rect, CGFloat cornerRadius)
{
//
// Create the boundary path
//
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL,
rect.origin.x,
rect.origin.y + rect.size.height - cornerRadius);
// Top left corner
CGPathAddArcToPoint(path, NULL,
rect.origin.x,
rect.origin.y,
rect.origin.x + rect.size.width,
rect.origin.y,
cornerRadius);
// Top right corner
CGPathAddArcToPoint(path, NULL,
rect.origin.x + rect.size.width,
rect.origin.y,
rect.origin.x + rect.size.width,
rect.origin.y + rect.size.height,
cornerRadius);
// Bottom right corner
CGPathAddArcToPoint(path, NULL,
rect.origin.x + rect.size.width,
rect.origin.y + rect.size.height,
rect.origin.x,
rect.origin.y + rect.size.height,
cornerRadius);
// Bottom left corner
CGPathAddArcToPoint(path, NULL,
rect.origin.x,
rect.origin.y + rect.size.height,
rect.origin.x,
rect.origin.y,
cornerRadius);
// Close the path at the rounded rect
CGPathCloseSubpath(path);
return path;
}
#implementation HelpView
#synthesize closeButton = _closeButton;
- (id)loadingViewInView:(UIView *)aSuperview
{
HelpView *loadingView =
[[HelpView alloc] initWithFrame:[aSuperview bounds]];
if (!loadingView)
{
return nil;
}
loadingView.opaque = NO;
loadingView.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[aSuperview addSubview:loadingView];
const CGFloat DEFAULT_LABEL_WIDTH = 100.0;
const CGFloat DEFAULT_LABEL_HEIGHT = 40.0;
CGRect labelFrame = CGRectMake(0, 0, DEFAULT_LABEL_WIDTH, DEFAULT_LABEL_HEIGHT);
UILabel *loadingLabel = [[UILabel alloc] initWithFrame:labelFrame];
loadingLabel.text = NSLocalizedString(#"Close", nil);
loadingLabel.textColor = [UIColor whiteColor];
loadingLabel.backgroundColor = [UIColor clearColor];
loadingLabel.textAlignment = UITextAlignmentCenter;
loadingLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
loadingLabel.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin;
// Background for Close button
CALayer *closeButtonBackground = [CALayer layer];
closeButtonBackground.opacity = 0.3;
closeButtonBackground.borderColor = [UIColor whiteColor].CGColor;
closeButtonBackground.borderWidth = 2.0;
closeButtonBackground.cornerRadius = 5.0;
closeButtonBackground.backgroundColor = [UIColor blackColor].CGColor;
// Finish setting up frame for Close button
labelFrame.origin.x = 0;
labelFrame.origin.y = 0;
loadingLabel.frame = labelFrame;
closeButtonBackground.frame = labelFrame;
CGRect viewRect = CGRectMake(loadingView.frame.size.width -150 ,loadingView.frame.size.height - 85,100,40);
self.closeButton = [[UIView alloc] initWithFrame:viewRect];
self.closeButton.userInteractionEnabled = YES;
self.userInteractionEnabled = NO;
[loadingView addSubview:self.closeButton];
[self.closeButton.layer addSublayer:closeButtonBackground];
[self.closeButton addSubview:loadingLabel];
// Set up the fade-in animation
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[aSuperview layer] addAnimation:animation forKey:#"layerAnimation"];
//[loadingView createGestureRecognizer];
return loadingView;
}
- (void)removeView
{
UIView *aSuperview = [self superview];
[super removeFromSuperview];
// Set up the animation
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[[aSuperview layer] addAnimation:animation forKey:#"layerAnimation"];
}
- (void)drawRect:(CGRect)rect
{
rect.size.height -= 1;
rect.size.width -= 1;
const CGFloat RECT_PADDING = 0.0;
rect = CGRectInset(rect, RECT_PADDING, RECT_PADDING);
const CGFloat ROUND_RECT_CORNER_RADIUS = 0.0;
CGPathRef roundRectPath = NewPathWithRoundRect(rect, ROUND_RECT_CORNER_RADIUS);
CGContextRef context = UIGraphicsGetCurrentContext();
const CGFloat BACKGROUND_OPACITY = 0.85;
CGContextSetRGBFillColor(context, 0, 0, 0, BACKGROUND_OPACITY);
CGContextAddPath(context, roundRectPath);
CGContextFillPath(context);
const CGFloat STROKE_OPACITY = 0.25;
CGContextSetRGBStrokeColor(context, 1, 1, 1, STROKE_OPACITY);
CGContextAddPath(context, roundRectPath);
CGContextStrokePath(context);
CGPathRelease(roundRectPath);
}
- (void)handleSingleDoubleTap:(UITapGestureRecognizer *)sender {
NSLog(#"");
CGPoint tapPoint = [sender locationInView:sender.view];
CALayer* layerThatWasTapped = [self.layer hitTest:tapPoint];
CGPoint convertedPoint = [layerThatWasTapped convertPoint:layerThatWasTapped.position toLayer:self.closeButton.layer];
BOOL myBool = [self.closeButton.layer containsPoint:convertedPoint];
[UIView beginAnimations:nil context:NULL];
sender.view.center = tapPoint;
[UIView commitAnimations];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView: self];
CGPoint convertedPoint = [self convertPoint:point toView:[self.closeButton superview]];
if (CGRectContainsPoint(self.closeButton.bounds, convertedPoint)) {
NSLog (#"YAY!");
}
} // touchesEnded

Solved this with NSNotifications. Something like this... its a little static... should be more dynamic.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:#selector(eventHandler:)
name:#"SomeButtonClicked"
object:nil ];
-(void)eventHandler: (NSNotification *) notification
{
NSString *buttonWhichWasClicked = [[notification userInfo] objectForKey:#"buttonName"];
NSLog(#" %#", buttonWhichWasClicked);
if ([buttonWhichWasClicked isEqualToString:#"close"]){
[self removeView];
}
//Tell other buttons to dim/remove themselves as a new one was selected
}
- (void)removeView
{
//code to remove view
}

Related

UiButton action method not working

I have a banner view that comes over navigation. I have added a custom button that i have added like:
- (id) initWithNotification:(JCNotificationBanner*)notification {
self = [super init];
if (self) {
isPresentedMutex = [NSObject new];
self.backgroundColor = [UIColor clearColor];
self.iconImageView = [UIImageView new];
self.iconImageView.image = [UIImage imageNamed:#"close.png"];
[self addSubview:self.iconImageView];
self.titleLabel = [UILabel new];
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = [UIColor lightTextColor];
self.titleLabel.backgroundColor = [UIColor clearColor];
[self addSubview:self.titleLabel];
self.messageLabel = [UILabel new];
self.messageLabel.font = [UIFont systemFontOfSize:14];
self.messageLabel.textColor = [UIColor lightTextColor];
self.messageLabel.backgroundColor = [UIColor clearColor];
self.messageLabel.numberOfLines = 0;
[self addSubview:self.messageLabel];
// Button
_detailDisclosureButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_detailDisclosureButton setBackgroundImage:[UIImage imageNamed:#"disclosure.png"] forState:UIControlStateNormal];
[_detailDisclosureButton setBackgroundImage:nil forState:UIControlStateSelected];
// _detailDisclosureButton.hidden = NO;
[_detailDisclosureButton addTarget:self action:#selector(detailDisclosureButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[_detailDisclosureButton setEnabled:YES];
[self addSubview:_detailDisclosureButton];
UITapGestureRecognizer* tapRecognizer;
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:#selector(handleSingleTap:)];
[self addGestureRecognizer:tapRecognizer];
self.notificationBanner = notification;
}
return self;
}
Here is what my draw context method is calling.
- (void) drawRect:(CGRect)rect {
CGRect bounds = self.bounds;
CGFloat lineWidth = kJCNotificationBannerViewOutlineWidth;
CGFloat radius = 10;
CGFloat height = bounds.size.height;
CGFloat width = bounds.size.width;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
CGMutablePathRef outlinePath = CGPathCreateMutable();
CGPathMoveToPoint(outlinePath, NULL, lineWidth, 0);
CGPathAddLineToPoint(outlinePath, NULL, lineWidth, height - radius - lineWidth);
CGPathAddArc(outlinePath, NULL, radius + lineWidth, height - radius - lineWidth, radius, -M_PI, M_PI_2, 1);
CGPathAddLineToPoint(outlinePath, NULL, width - radius - lineWidth, height - lineWidth);
CGPathAddArc(outlinePath, NULL, width - radius - lineWidth, height - radius - lineWidth, radius, M_PI_2, 0, 1);
CGPathAddLineToPoint(outlinePath, NULL, width - lineWidth, 0);
CGContextSetRGBFillColor(context, 0, 0, 0, 0.9);
CGContextAddPath(context, outlinePath);
CGContextFillPath(context);
CGContextAddPath(context, outlinePath);
CGContextSetRGBFillColor(context, 0, 0, 0, 1);
CGContextSetLineWidth(context, lineWidth);
CGContextDrawPath(context, kCGPathStroke);
CGPathRelease(outlinePath);
}
And my layout subview methods that arrange frame are like:
- (void) layoutSubviews {
if (!(self.frame.size.width > 0)) { return; }
BOOL hasTitle = notificationBanner ? (notificationBanner.title.length > 0) : NO;
CGFloat borderY = kJCNotificationBannerViewOutlineWidth + kJCNotificationBannerViewMarginY;
CGFloat borderX = kJCNotificationBannerViewOutlineWidth + kJCNotificationBannerViewMarginX;
CGFloat currentX = borderX;
CGFloat currentY = borderY;
CGFloat contentWidth = self.frame.size.width - (borderX * 2.0);
currentY += 2.0;
if (hasTitle) {
self.titleLabel.frame = CGRectMake(currentX, currentY, contentWidth, 22.0);
currentY += 22.0;
}
self.messageLabel.frame = CGRectMake(currentX, currentY, contentWidth, (self.frame.size.height - borderY) - currentY);
[self.messageLabel sizeToFit];
CGRect messageFrame = self.messageLabel.frame;
CGFloat spillY = (currentY + messageFrame.size.height + kJCNotificationBannerViewMarginY) - self.frame.size.height;
if (spillY > 0.0) {
messageFrame.size.height -= spillY;
self.messageLabel.frame = messageFrame;
}
_detailDisclosureButton.frame = CGRectMake(285,self.center.y-15,29,29);
}
My Button action method named detailDisclosureButtonPressed is not being called. Please help me out in this ?

Objective-C Moving object along curved path

I've looked at other SO answers to this quesiton, particularly Brad Larson's but I am still not getting any results. I'm not sure if I am approaching this the correct way. In my app, when a user touches the screen I capture the point and create an arc from a fixed point to that touch point. I then want to move a UIView along that arc.
Here's my code:
ViewController.m
//method to "shoot" object - KIP_Projectile creates the arc, KIP_Character creates the object I want to move along the arc
...
//get arc for trajectory
KIP_Projectile* vThisProjectile = [[KIP_Projectile alloc] initWithFrame:CGRectMake(51.0, fatElvisCenterPoint-30.0, touchPoint.x, 60.0)];
vThisProjectile.backgroundColor = [UIColor clearColor];
[self.view addSubview:vThisProjectile];
...
KIP_Character* thisChar = [[KIP_Character alloc] initWithFrame:CGRectMake(51, objCenterPoint-5, imgThisChar.size.width, imgThisChar.size.height)];
thisChar.backgroundColor = [UIColor clearColor];
thisChar.charID = charID;
thisChar.charType = 2;
thisChar.strCharType = #"Projectile";
thisChar.imgMyImage = imgThisChar;
thisChar.myArc = vThisProjectile;
[thisChar buildImage];
[thisChar traceArc];
in KIP_Projectile I build the arc using this code:
- (CGMutablePathRef) createArcPathFromBottomOfRect : (CGRect) rect : (CGFloat) arcHeight {
CGRect arcRect = CGRectMake(rect.origin.x, rect.origin.y + rect.size.height - arcHeight, rect.size.width, arcHeight);
CGFloat arcRadius = (arcRect.size.height/2) + (pow(arcRect.size.width, 2) / (8*arcRect.size.height));
CGPoint arcCenter = CGPointMake(arcRect.origin.x + arcRect.size.width/2, arcRect.origin.y + arcRadius);
CGFloat angle = acos(arcRect.size.width / (2*arcRadius));
CGFloat startAngle = radians(180) + angle;
CGFloat endAngle = radians(360) - angle;
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path, NULL, arcCenter.x, arcCenter.y, arcRadius, startAngle, endAngle, 0);
return path;
}
- (void)drawRect:(CGRect)rect {
CGContextRef currentContext = UIGraphicsGetCurrentContext();
_myArcPath = [self createArcPathFromBottomOfRect:self.bounds:30.0];
CGContextSetLineWidth(currentContext, 1);
CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetStrokeColor(currentContext, red);
CGContextAddPath(currentContext, _myArcPath);
CGContextStrokePath(currentContext);
}
Works fine. The arc is displayed with a red stroke on the screen.
In KIP_Character, which has been passed it's relevant arc, I am using this code but getting no results.
- (void) traceArc {
CGMutablePathRef myArc = _myArc.myArcPath;
// Set up path movement
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:#"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
pathAnimation.path = myArc;
CGPathRelease(myArc);
[self.layer addAnimation:pathAnimation forKey:#"savingAnimation"];
}
Any help here would be appreciated.

How to animate zooming UIView WITH SUBVIEWS?

This code does the following: It takes a 'snapshot' of a NavigationController meant to disappear. Then the snapshot is added to the view of a container view controller, slides away and reveals the new NavigationController. To create the 'Pop-Out-Effect' the midAnFrame makes the view a bit bigger than the actual view. After that postAnFrame provides the sliding out of the container view's frame. Works great, the only problem is that the subviews of animationContainer don't resize like their superView during the animation.
- (void)bringUpSettingsNavigationController {
CGFloat gradientWidth = 20;
CGFloat frameIncrease = 10;
CGRect preAnFrame = CGRectMake(- gradientWidth, 0, self.view.frame.size.width + gradientWidth, self.view.frame.size.height);
CGRect midAnFrame = CGRectMake(-(frameIncrease + gradientWidth), - frameIncrease, preAnFrame.size.width + (2*frameIncrease), preAnFrame.size.height + (2*frameIncrease));
CGRect postAnFrame = CGRectMake(midAnFrame.size.width, midAnFrame.origin.y, midAnFrame.size.width, midAnFrame.size.height);
UIView *animationContainer = [[UIView alloc]initWithFrame:preAnFrame];
animationContainer.backgroundColor = [UIColor clearColor];
animationContainer.autoresizesSubviews = YES;
self.topImageView = [[UIImageView alloc]initWithImage:[self topImageFromView:self.view]];
self.topImageView.frame = CGRectMake(gradientWidth, 0, preAnFrame.size.width - gradientWidth, preAnFrame.size.height);
[animationContainer addSubview:self.topImageView];
self.topImageView.clipsToBounds = YES;
UIView *gradientView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, gradientWidth, preAnFrame.size.height)];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = gradientView.bounds;
gradientLayer.colors = [NSArray arrayWithObjects:(id)[[UIColor clearColor] CGColor], (id)[[UIColor colorWithWhite:0 alpha:.5] CGColor], nil];
gradientLayer.startPoint = CGPointMake(0, 0.5);
gradientLayer.endPoint = CGPointMake(1.0, 0.5);
[gradientView.layer insertSublayer:gradientLayer atIndex:0];
gradientView.backgroundColor = [UIColor clearColor];
[animationContainer addSubview:gradientView];
gradientView.clipsToBounds = YES;
[self.view addSubview:animationContainer];
BYSettingsNavigationController *settingsNavigationController = [[BYSettingsNavigationController alloc]initWithRootViewController:[[BYSettingsViewController alloc]init]];
[self addChildViewController:settingsNavigationController];
settingsNavigationController.view.frame = self.view.bounds;
[self.view insertSubview:settingsNavigationController.view belowSubview:animationContainer];
[settingsNavigationController didMoveToParentViewController:self];
[UIView animateWithDuration:0.2 animations:^{
animationContainer.frame = midAnFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:.5 animations:^{
animationContainer.frame = postAnFrame;
} completion:^(BOOL finished) {
[self.topImageView removeFromSuperview];
[gradientView removeFromSuperview];
self.topImageView = nil;
}];
}];
[self.currentNavigationController willMoveToParentViewController:nil];
[self.currentNavigationController.view removeFromSuperview];
[self.currentNavigationController removeFromParentViewController];
}
Thanks in advance for your ideas and have a great 2013!
Dario
What your doing is not zooming in , your just changing the frame size.
To zoom in you need to change the transformation of the view.
What you need to do is something along this line:
view.transform = CGAffineTransformMakeScale (2.0 , 2.0);
for example to zoom X2

Using NSPoint Mouse Tracking on NSView

I have this method in App Delegate that makes a window and content view but I want to be able to track the mouse using an NSPoint on entered and exiting the view. The problem is I do not want to make a NSView Custom class and want to do it all within my AppDelegate. The mouse tracking (at the bottom) does not work, any suggestions?
- (void)toggleHelpDisplay
{
// Create helpWindow.
NSRect mainFrame = [[NSScreen mainScreen] frame];
NSRect helpFrame = NSZeroRect;
float width = 75;
float height = 75;
helpFrame.origin.x = (mainFrame.size.width - width) / 2.0;
helpFrame.origin.y = 200.0;
helpFrame.size.width = width;
helpFrame.size.height = height;
helpWindow = [[BrightnessView windowWithFrame:helpFrame] retain];
// Configure window.
[helpWindow setReleasedWhenClosed:YES];
[helpWindow setHidesOnDeactivate:NO];
[helpWindow setCanHide:NO];
[helpWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
[helpWindow setIgnoresMouseEvents:NO];
// Configure contentView.
NSView *contentView = [helpWindow contentView];
[contentView setWantsLayer:YES];
CATextLayer *layer = [CATextLayer layer];
layer.opacity = 0;
[contentView setLayer:layer];
CGColorRef bgColor = CGColorCreateGenericGray(0.0, 0.6);
layer.backgroundColor = bgColor;
CGColorRelease(bgColor);
layer.string = ? HELP_TEXT : HELP_TEXT_OFF;
layer.contentsRect = CGRectMake(0, 0, 1, 1.2);
layer.fontSize = 40.0;
layer.foregroundColor = CGColorGetConstantColor(kCGColorWhite);
layer.borderColor = CGColorGetConstantColor(kCGColorWhite);
layer.borderWidth = 4.0;
layer.cornerRadius = 4.0;
layer.alignmentMode = kCAAlignmentCenter;
[window addChildWindow:helpWindow ordered:NSWindowAbove];
float helpOpacity = (([NSApp isActive] ? 1 : 0));
[[[helpWindow contentView] layer] setOpacity:helpOpacity];
//track mouse so that once hovered make larger.
NSPoint mouseLocation = [[self window] mouseLocationOutsideOfEventStream];
if (NSPointInRect(mouseLocation, helpFrame)) {
NSLog(#"mouse over");
}
else
{
NSLog(#"mouse not over");
}
}
You should be able to do this using NSTrackingArea; You'd do something like this (typed in the browser, not tested):
self.helpView = contentView; // Need to store a reference to the view if you want to convert from its coordinate system
// Set up a tracking area
NSTrackingArea *trackingArea = [[[NSTrackingArea alloc] initWithRect:[self.helpView bounds]
options:NSTrackingActiveInActiveApp | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved
owner:self
userInfo:nil] autorelease];
[self.helpView addTrackingArea:trackingArea];
- (void)mouseEntered:(NSEvent *)event;
{
NSPoint location = [self.helpView convertPoint:[event locationInWindow] fromView:nil];
// Do whatever you want to do in response to mouse entering
}
- (void)mouseExited:(NSEvent *)event;
{
NSPoint location = [self.helpView convertPoint:[event locationInWindow] fromView:nil];
// Do whatever you want to do in response to mouse exiting
}
- (void)mouseMoved:(NSEvent *)event;
{
NSPoint location = [self.helpView convertPoint:[event locationInWindow] fromView:nil];
// Do whatever you want to do in response to mouse movements
}

Zooming and Rotation an UIImageView

I would like to zoom and rotate an UIImageView. Here is my code:
#synthesize immagine, velocita, locationManager, direzione;
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{
double degrees = newHeading.magneticHeading;
double radians = degrees * M_PI / 180;
[UIView animateWithDuration:0.05 animations:^{
self.immagine.transform = CGAffineTransformMakeRotation(-radians);
}];
}
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
return immagine;
}
- (void)viewDidLoad
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
[scrollView setDelegate:self];
[scrollView setContentSize:CGSizeMake(320, 460)];
immagine = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"mappa1"]];
immagine.frame = CGRectMake(0, 0, 320, 460);
immagine.contentMode = UIViewContentModeScaleAspectFit;
[scrollView addSubview:immagine];
locationManager.headingFilter = kCLHeadingFilterNone;
[locationManager startUpdatingHeading];
[super viewDidLoad];
}
But when I'm zooming, the UIImageView exit from the View. Can anyone help me? Thanks in advance!
I have problem like this and these two function will solve your problem
- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
CGRect originalFrame=recognizer.view.frame;
CGRect newFrame=CGRectMake(originalFrame.origin.x, originalFrame.origin.y, originalFrame.size.width*recognizer.scale, originalFrame.size.height*recognizer.scale);
if (newFrame.size.width>70&&newFrame.size.width<150)
{
recognizer.view.frame=newFrame;
}
}
- (void)twoFingersRotate:(UIRotationGestureRecognizer *)recognizer
{
[self.view bringSubviewToFront:[(UIRotationGestureRecognizer*)recognizer view]];
if([(UIRotationGestureRecognizer*)recognizer state] == UIGestureRecognizerStateEnded) {
lastRotation = 0.0;
return;
}
CGFloat rotation = 0.0 - (lastRotation - [(UIRotationGestureRecognizer*)recognizer rotation]);
CGAffineTransform currentTransform = [(UIPinchGestureRecognizer*)recognizer view].transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation);
[[(UIRotationGestureRecognizer*)recognizer view] setTransform:newTransform];
lastRotation = [(UIRotationGestureRecognizer*)recognizer rotation];
// recognizer.view.transform=CGAffineTransformMakeRotation(([recognizer rotation] * 180) / M_PI);
}