iphone Programming Glossary: cgpoint
How do I make UILabel display outlined text? http://stackoverflow.com/questions/1103148/how-do-i-make-uilabel-display-outlined-text str CGContextSetTextDrawingMode gc kCGTextInvisible CGContextShowTextAtPoint gc 0 0 str strlen str CGPoint pt CGContextGetTextPosition gc CGContextSetTextDrawingMode gc kCGTextFillStroke CGContextShowTextAtPoint..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path imageViewForAnimation.frame Your image frame.origin from where the animation need to get start CGPoint viewOrigin imageViewForAnimation.frame.origin viewOrigin.y viewOrigin.y imageFrame.size.height 2.0f.. kCAFillModeForwards pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake.. pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake 320 40.0f 480.0f..
UIScrollView horizontal paging like Mobile Safari tabs http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs . The final step is to override UIView hitTest withEvent inside the ClipView . UIView hitTest CGPoint point withEvent UIEvent event if self pointInside point withEvent event return scrollView return nil.. what you need. Another option would be to subclass UIScrollView and override its BOOL pointInside CGPoint point withEvent UIEvent event method however you will still need a container view to do the clipping..
Detecting which UIButton was pressed in a UITableView http://stackoverflow.com/questions/1802707/detecting-which-uibutton-was-pressed-in-a-uitableview retrieved and index path is calculated from that coordinate void checkButtonTapped id sender CGPoint buttonPosition sender convertPoint CGPointZero toView self.tableView NSIndexPath indexPath self.tableView.. from that coordinate void checkButtonTapped id sender CGPoint buttonPosition sender convertPoint CGPointZero toView self.tableView NSIndexPath indexPath self.tableView indexPathForRowAtPoint buttonPosition..
iPhone image stretching (skew) http://stackoverflow.com/questions/2351586/iphone-image-stretching-skew image stretching skew How do I skew an image For example each corner has a CGPoint with coords p1 p2 p3 p4. Then I need to set p4.x 50 p4.y 30. So this corner p4 should be stretched in..
How can i change the color of pagination dots of UIPageControl? http://stackoverflow.com/questions/2942636/how-can-i-change-the-color-of-pagination-dots-of-uipagecontrol super dealloc void touchesBegan NSSet touches withEvent UIEvent event if self.delegate return CGPoint touchPoint event touchesForView self anyObject locationInView self CGFloat dotSpanX self.numberOfPages..
Basic Drag and Drop in iOS http://stackoverflow.com/questions/4707858/basic-drag-and-drop-in-ios the UIControlEventTouchDragInside event e.g. IBAction imageMoved id sender withEvent UIEvent event CGPoint point event allTouches anyObject locationInView self.view UIControl control sender control.center point..
iPhone smooth sketch drawing algorithm http://stackoverflow.com/questions/5076622/iphone-smooth-sketch-drawing-algorithm event then I draw all the points in the array using NSMutableArray points collectedArray points CGPoint firstPoint points objectAtIndex 0 getValue firstPoint CGContextMoveToPoint context firstPoint.x firstPoint.y.. context kCGLineJoinRound for int i 1 i points count i NSValue value points objectAtIndex i CGPoint point value getValue point CGContextAddLineToPoint context point.x point.y CGContextStrokePath context..
UIImage: Resize, then Crop http://stackoverflow.com/questions/603907/uiimage-resize-then-crop CGFloat scaleFactor 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor.. 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor targetWidth width CGFloat..
How to know the UITableview row number http://stackoverflow.com/questions/9274494/how-to-know-the-uitableview-row-number Tags subclasses or view hierarchy navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint.. navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint hitPoint Works..
Transforming a rectangle image into a quadrilateral using a CATransform3D http://stackoverflow.com/questions/9470493/transforming-a-rectangle-image-into-a-quadrilateral-using-a-catransform3d doing this on iOS https github.com hfossli AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL.. Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self.. is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad rect quadTLX..
How do I make UILabel display outlined text? http://stackoverflow.com/questions/1103148/how-do-i-make-uilabel-display-outlined-text CGContextRef gc float x float y const char str CGContextSetTextDrawingMode gc kCGTextInvisible CGContextShowTextAtPoint gc 0 0 str strlen str CGPoint pt CGContextGetTextPosition gc CGContextSetTextDrawingMode gc kCGTextFillStroke CGContextShowTextAtPoint gc x pt.x 2 y str strlen str void drawRect CGRect rect..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path imageViewForAnimation.alpha 1.0f CGRect imageFrame imageViewForAnimation.frame Your image frame.origin from where the animation need to get start CGPoint viewOrigin imageViewForAnimation.frame.origin viewOrigin.y viewOrigin.y imageFrame.size.height 2.0f viewOrigin.x viewOrigin.x imageFrame.size.width 2.0f imageViewForAnimation.frame.. kCAAnimationPaced pathAnimation.fillMode kCAFillModeForwards pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake 320 40.0f 480.0f CGMutablePathRef curvedPath CGPathCreateMutable.. kCAAnimationPaced pathAnimation.fillMode kCAFillModeForwards pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake 320 40.0f 480.0f CGMutablePathRef curvedPath CGPathCreateMutable CGPathMoveToPoint..
UIScrollView horizontal paging like Mobile Safari tabs http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs view. Also the ClipView needs a reference to the UIScrollView . The final step is to override UIView hitTest withEvent inside the ClipView . UIView hitTest CGPoint point withEvent UIEvent event if self pointInside point withEvent event return scrollView return nil This basically expands the touch area of the UIScrollView to.. the UIScrollView to the frame of its parent's view exactly what you need. Another option would be to subclass UIScrollView and override its BOOL pointInside CGPoint point withEvent UIEvent event method however you will still need a container view to do the clipping and it may be difficult to determine when to return YES based..
Detecting which UIButton was pressed in a UITableView http://stackoverflow.com/questions/1802707/detecting-which-uibutton-was-pressed-in-a-uitableview Then in touch handler touch coordinate retrieved and index path is calculated from that coordinate void checkButtonTapped id sender CGPoint buttonPosition sender convertPoint CGPointZero toView self.tableView NSIndexPath indexPath self.tableView indexPathForRowAtPoint buttonPosition if indexPath nil..
iPhone image stretching (skew) http://stackoverflow.com/questions/2351586/iphone-image-stretching-skew image stretching skew How do I skew an image For example each corner has a CGPoint with coords p1 p2 p3 p4. Then I need to set p4.x 50 p4.y 30. So this corner p4 should be stretched in a 2D perspective and the image should be distorted. I tried..
How can i change the color of pagination dots of UIPageControl? http://stackoverflow.com/questions/2942636/how-can-i-change-the-color-of-pagination-dots-of-uipagecontrol release dotColorOtherPage release delegate release super dealloc void touchesBegan NSSet touches withEvent UIEvent event if self.delegate return CGPoint touchPoint event touchesForView self anyObject locationInView self CGFloat dotSpanX self.numberOfPages kDotDiameter kDotSpacer CGFloat dotSpanY kDotDiameter kDotSpacer..
Basic Drag and Drop in iOS http://stackoverflow.com/questions/4707858/basic-drag-and-drop-in-ios you may move the vehicle wherever you want by responding to the UIControlEventTouchDragInside event e.g. IBAction imageMoved id sender withEvent UIEvent event CGPoint point event allTouches anyObject locationInView self.view UIControl control sender control.center point It's a lot easier for individual vehicle to handle its own..
iPhone smooth sketch drawing algorithm http://stackoverflow.com/questions/5076622/iphone-smooth-sketch-drawing-algorithm I called void touchesEnded NSSet touches withEvent UIEvent event then I draw all the points in the array using NSMutableArray points collectedArray points CGPoint firstPoint points objectAtIndex 0 getValue firstPoint CGContextMoveToPoint context firstPoint.x firstPoint.y CGContextSetLineCap context kCGLineCapRound CGContextSetLineJoin.. CGContextSetLineCap context kCGLineCapRound CGContextSetLineJoin context kCGLineJoinRound for int i 1 i points count i NSValue value points objectAtIndex i CGPoint point value getValue point CGContextAddLineToPoint context point.x point.y CGContextStrokePath context UIGraphicsPushContext context And now I want to improve the..
UIImage: Resize, then Crop http://stackoverflow.com/questions/603907/uiimage-resize-then-crop targetWidth targetSize.width CGFloat targetHeight targetSize.height CGFloat scaleFactor 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor targetWidth width CGFloat heightFactor targetHeight height.. CGFloat targetHeight targetSize.height CGFloat scaleFactor 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor targetWidth width CGFloat heightFactor targetHeight height if widthFactor heightFactor..
How to know the UITableview row number http://stackoverflow.com/questions/9274494/how-to-know-the-uitableview-row-number iphone ios uitableview uiswitch share improve this question Tags subclasses or view hierarchy navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint hitPoint Works with any type of view multi.. improve this question Tags subclasses or view hierarchy navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint hitPoint Works with any type of view multi section tables whatever you can..
Transforming a rectangle image into a quadrilateral using a CATransform3D http://stackoverflow.com/questions/9470493/transforming-a-rectangle-image-into-a-quadrilateral-using-a-catransform3d share improve this question I've created a kit for doing this on iOS https github.com hfossli AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad.. doing this on iOS https github.com hfossli AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad rect quadTLX topLeft.x quadTLY topLeft.y quadTRX.. github.com hfossli AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad rect quadTLX topLeft.x quadTLY topLeft.y quadTRX topRight.x quadTRY topRight.y..
How do I make UILabel display outlined text? http://stackoverflow.com/questions/1103148/how-do-i-make-uilabel-display-outlined-text float y const char str CGContextSetTextDrawingMode gc kCGTextInvisible CGContextShowTextAtPoint gc 0 0 str strlen str CGPoint pt CGContextGetTextPosition gc CGContextSetTextDrawingMode gc kCGTextFillStroke CGContextShowTextAtPoint gc x pt.x 2 y str..
How can I animate the movement of a view or image along a curved path? http://stackoverflow.com/questions/1142727/how-can-i-animate-the-movement-of-a-view-or-image-along-a-curved-path 1.0f CGRect imageFrame imageViewForAnimation.frame Your image frame.origin from where the animation need to get start CGPoint viewOrigin imageViewForAnimation.frame.origin viewOrigin.y viewOrigin.y imageFrame.size.height 2.0f viewOrigin.x viewOrigin.x.. pathAnimation.fillMode kCAFillModeForwards pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake 320 40.0f 480.0f CGMutablePathRef.. kCAFillModeForwards pathAnimation.removedOnCompletion NO Setting Endpoint of the animation CGPoint endPoint CGPointMake 480.0f 30.0f 40.0f to end animation in last tab use CGPoint endPoint CGPointMake 320 40.0f 480.0f CGMutablePathRef curvedPath..
UIScrollView horizontal paging like Mobile Safari tabs http://stackoverflow.com/questions/1220354/uiscrollview-horizontal-paging-like-mobile-safari-tabs to the UIScrollView . The final step is to override UIView hitTest withEvent inside the ClipView . UIView hitTest CGPoint point withEvent UIEvent event if self pointInside point withEvent event return scrollView return nil This basically expands.. view exactly what you need. Another option would be to subclass UIScrollView and override its BOOL pointInside CGPoint point withEvent UIEvent event method however you will still need a container view to do the clipping and it may be difficult..
Detecting which UIButton was pressed in a UITableView http://stackoverflow.com/questions/1802707/detecting-which-uibutton-was-pressed-in-a-uitableview handler touch coordinate retrieved and index path is calculated from that coordinate void checkButtonTapped id sender CGPoint buttonPosition sender convertPoint CGPointZero toView self.tableView NSIndexPath indexPath self.tableView indexPathForRowAtPoint.. path is calculated from that coordinate void checkButtonTapped id sender CGPoint buttonPosition sender convertPoint CGPointZero toView self.tableView NSIndexPath indexPath self.tableView indexPathForRowAtPoint buttonPosition if indexPath nil .....
iPhone image stretching (skew) http://stackoverflow.com/questions/2351586/iphone-image-stretching-skew image stretching skew How do I skew an image For example each corner has a CGPoint with coords p1 p2 p3 p4. Then I need to set p4.x 50 p4.y 30. So this corner p4 should be stretched in a 2D perspective and..
How can i change the color of pagination dots of UIPageControl? http://stackoverflow.com/questions/2942636/how-can-i-change-the-color-of-pagination-dots-of-uipagecontrol release delegate release super dealloc void touchesBegan NSSet touches withEvent UIEvent event if self.delegate return CGPoint touchPoint event touchesForView self anyObject locationInView self CGFloat dotSpanX self.numberOfPages kDotDiameter kDotSpacer..
Basic Drag and Drop in iOS http://stackoverflow.com/questions/4707858/basic-drag-and-drop-in-ios by responding to the UIControlEventTouchDragInside event e.g. IBAction imageMoved id sender withEvent UIEvent event CGPoint point event allTouches anyObject locationInView self.view UIControl control sender control.center point It's a lot easier..
UIView drag (image and text) http://stackoverflow.com/questions/4982277/uiview-drag-image-and-text at the following example. void touchesMoved NSSet touches withEvent UIEvent event UITouch aTouch touches anyObject CGPoint location aTouch locationInView self.superview UIView beginAnimations @ Dragging A DraggableView context nil self.frame CGRectMake..
iPhone smooth sketch drawing algorithm http://stackoverflow.com/questions/5076622/iphone-smooth-sketch-drawing-algorithm withEvent UIEvent event then I draw all the points in the array using NSMutableArray points collectedArray points CGPoint firstPoint points objectAtIndex 0 getValue firstPoint CGContextMoveToPoint context firstPoint.x firstPoint.y CGContextSetLineCap.. CGContextSetLineJoin context kCGLineJoinRound for int i 1 i points count i NSValue value points objectAtIndex i CGPoint point value getValue point CGContextAddLineToPoint context point.x point.y CGContextStrokePath context UIGraphicsPushContext..
UIImage: Resize, then Crop http://stackoverflow.com/questions/603907/uiimage-resize-then-crop targetSize.height CGFloat scaleFactor 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor targetWidth width CGFloat.. CGFloat scaleFactor 0.0 CGFloat scaledWidth targetWidth CGFloat scaledHeight targetHeight CGPoint thumbnailPoint CGPointMake 0.0 0.0 if CGSizeEqualToSize imageSize targetSize NO CGFloat widthFactor targetWidth width CGFloat heightFactor targetHeight..
UIButton can't be touched while animated with UIView animateWithDuration http://stackoverflow.com/questions/8346100/uibutton-cant-be-touched-while-animated-with-uiview-animatewithduration and add it to your project. void touchesBegan NSSet touches withEvent UIEvent event UITouch touch touches anyObject CGPoint touchLocation touch locationInView self.view for UIButton button in self.buttonsOutletCollection if button.layer.presentationLayer..
How to know the UITableview row number http://stackoverflow.com/questions/9274494/how-to-know-the-uitableview-row-number improve this question Tags subclasses or view hierarchy navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint.. or view hierarchy navigation are too much work . Do this in your action method CGPoint hitPoint sender convertPoint CGPointZero toView self.tableView NSIndexPath hitIndex self.tableView indexPathForRowAtPoint hitPoint Works with any type of view..
Transforming a rectangle image into a quadrilateral using a CATransform3D http://stackoverflow.com/questions/9470493/transforming-a-rectangle-image-into-a-quadrilateral-using-a-catransform3d created a kit for doing this on iOS https github.com hfossli AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft .. AGGeometryKit Make sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad rect quadTLX.. sure your anchor point is top left CGPointZero . CATransform3D rectToQuad CGRect rect quadTL CGPoint topLeft quadTR CGPoint topRight quadBL CGPoint bottomLeft quadBR CGPoint bottomRight return self rectToQuad rect quadTLX topLeft.x quadTLY topLeft.y..
|