Questions tagged [cgpoint]

CGPoint is a structure from Apple's Core Graphics framework. It is used to represent a point in two dimensions.

CGPoint is a C struct that contains information about the location of a point in two dimensions.

Fields:

  • x: The X location of the point
  • y: The Y location of the point
509 questions
160
votes
8 answers

iOS: verify if a point is inside a rect

Is there a way to verify if a CGPoint is inside a specific CGRect? An example would be: I'm dragging a UIImageView and I want to verify if its central point CGPoint is inside another UIImageView.
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
53
votes
4 answers

How do I create a CGRect from a CGPoint and CGSize?

I need to create a frame for a UIImageView from a varying collection of CGSize and CGPoint, both values will always be different depending on user's choices. So how can I make a CGRect form a CGPoint and a CGSize? Thank you in advance.
inorganik
  • 24,255
  • 17
  • 90
  • 114
41
votes
6 answers

How do I add a CGPoint to NSMutableArray?

I want to store my CGPoint to the NSMutable Array, so , I have method like this: [self.points addObject:CGPointMake(x, y)]; But I got the error, it said that : Incompatible type for argument 1 of "addObject". So, I check out the API, -…
Tattat
  • 15,548
  • 33
  • 87
  • 138
31
votes
3 answers

Inheritance from non-protocol, non-class type 'CGPoint'

I want to create a custom CGPoint subclass to add some proprieties, but I get this error: Inheritance from non-protocol, non-class type 'CGPoint' I have no idea why this is not possible. My class is as simple as this: import UIKit class…
Philip Müller
  • 533
  • 1
  • 8
  • 13
31
votes
5 answers

CGPointMake in Swift

How to use CGPointMake in Swift? Is there an equivalent for it? I am getting an error: Use of unresolved identifier 'CGPointMake' Basically, I am trying to assign a position to a Sprite Kit node and cannot figure out how to do it in Swift. class…
Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
31
votes
6 answers

How to get a CGPoint from a tapped location?

I'm working on a graphing calculator app for the iPad, and I wanted to add a feature where a user can tap an area in the graph view to make a text box pop up displaying the coordinate of the point they touched. How can I get a CGPoint from this?
jkolber
  • 313
  • 1
  • 3
  • 5
29
votes
2 answers

Accessing the current position of UIView during animation

I am trying to find the current position of an iPhone ImageView that is animating across the screen. I create and animate the imageView like so -(IBAction)button:(UIButton *)sender{ UIImageView *myImageView =[[UIImageView alloc] initWithImage: …
user975134
  • 383
  • 1
  • 4
  • 15
29
votes
5 answers

How to test if a point is in a view

I have a UIImageView and I have a CGPoint on the screen. I want to be able to test that point to see if it is in the UIImageView. What would be the best way to do this?
Blane Townsend
  • 2,888
  • 5
  • 41
  • 55
29
votes
5 answers

How to draw a circle in swift using spriteKit?

I just started doing ios development with swift and I can't figure out how to draw a circle. I'm just trying to draw a circle, set it to a variable and display in on the screen so I can later use it as the main player. Could anyone tell me how to…
elpita
  • 1,085
  • 3
  • 12
  • 13
24
votes
1 answer

CGPoint relative to view

Consider a screen point (CGPoint) and a view (UIView), which is somewhere inside the view hierarchy (it can be a subview of other views). How can you convert the point to a point relative to the view's coordinates?
hpique
  • 119,096
  • 131
  • 338
  • 476
23
votes
7 answers

Turn two CGPoints into a CGRect

How can I, given two different CGPoints, turn them into an CGRect? Example: CGPoint p1 = CGPointMake(0,10); CGPoint p2 = CGPointMake(10,0); How can I turn this into a CGRect?
christo16
  • 4,843
  • 5
  • 42
  • 53
20
votes
5 answers

How to convert CGPoint in NSValue in swift?

As my question title says how can I convert CGPoint into NSValues so I can store then Into array In swift. In objective-C we can do it like this: // CGPoint converted to NSValue CGPoint point = CGPointMake(9, 9); NSValue *pointObj =…
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
19
votes
7 answers

Converting a CGPoint to NSValue

In CABasicAnimation.fromValue I want to convert a CGPoint to a "class" so I used NSValue valueWithPoint but in device mode or simulator one is not working... need to use NSMakePoint or CGPointMake if in device or simulator.
CiNN
  • 9,752
  • 6
  • 44
  • 57
18
votes
2 answers

Save list of CGPoints using NSUserDefaults

I have a bunch of CGPoints from a CCTMXLayer I want to save to NSUserDefaults but cannot seem to figure out an elegant way of doing so. Originally I was hoping to save an NSDictionary with an NSMutableSet for a value containing several NSValues…
Chris Daviduik
  • 336
  • 3
  • 10
12
votes
1 answer

Coordinates all wrong on iPhone 3G? It could be your compiler

Note: This is question to which I have already found an answer. It seems that posting a question after finding an interesting answer is encouraged, so I am posting this. Someone else is likely to have the same problem and find this useful. I have…
Clafou
  • 15,250
  • 7
  • 58
  • 89
1
2 3
33 34