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
1
vote
1 answer

Preserve Variable in a method

This should be easy. I've got a method to move a view up and down and while doing so I move a UIButton over and down... then move the button back to its original position when the method runs again. I thought I could get the original position of the…
Michael Morrison
  • 1,323
  • 1
  • 18
  • 30
1
vote
1 answer

SwiftUI: Convert from a CGPoint on screen to a CGPoint in a view

I have a view placed somewhere in my ContentView. I want to be able to drop images onto it. So I've added and .onDrop to it. In UIKit, I would use universeView.convert(point, to: targetView). How do I do this in SwiftUI? Example utility could be to…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
1
vote
3 answers

Random CGPointMake?

How can I make a random CGPointMake, say i created an outlet of a uiimage and called it image, image.center = CGPointMake (//random, //random) everytime second (NSTimer)
user840797
  • 36
  • 5
1
vote
2 answers

What kind of data does apple use on GLPaint example?

Few months ago i made an app based on apple GLPaint. It works great. I have recorded sets of points that draw simple drawings on the screen. and saved them as array of points (converted to NSValue). i am trying to improve my app now and i looked…
shannoga
  • 19,649
  • 20
  • 104
  • 169
1
vote
1 answer

draw line using uibezierPath in a vertical way

My swift code below draws a horiziontal way the horizontal line is at a angle that does not change. Think like a x axis. I want to draw a line in the exact opposite way. Think of the y axis. The line is drawn at bezier.addLine(to: CGPoint(x:…
joe buck
  • 31
  • 1
  • 7
1
vote
4 answers

Programmatically supply argument to cgpointmake or cgpoint to create cgpoints from coordinate pair

Please forgive this naive question, but is there any direct way to create a cgpoints from a coordinate pair without extracting the x and y value separately. I know you can do: CGPoint point = CGPointMake(2, 3); or float x = 2; float y = 3; CGPoint…
user6631314
  • 1,751
  • 1
  • 13
  • 44
1
vote
1 answer

Using CoreData with drawing (CGPoint)

I would like to use Core Data for a drawing application where the user draws in a UIImageView using CGPoints has the option to save and at a later time load different drawings (and add to them if the user desires - e.g. mutability) I've read through…
jamesC
  • 422
  • 6
  • 25
1
vote
1 answer

How to rotate a image from a specific anchor point

I want to rotate a image in this code would be pic1. I placed a image below of what I am exactly looking for. I don't want to rotate the entire image I want to rotate from the bottom left corner of the rectangle 90 degrees. You can see specifically…
user13245026
1
vote
1 answer

xcode CGPoint arc4random not working

I have 22 images... 11 are (rightwall1, rightwall2, rightwall3, etc) the other 11 are (leftwall1, leftwall2, leftwall3, etc) I am placing each one ontop of the other by setting their y value to the previous walls y value plus the height of the wall…
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
1
vote
3 answers

How do i find out if a touch is over the frame of another shape?

I know how to get the position touched, so now i have a CGPoint with the touched position. What's the best way to find out if the touch is over a UIView or not? I know of the method of: if touchpoint.x > frame.origin.x && touchpoint.x <…
Andrew
  • 15,935
  • 28
  • 121
  • 203
1
vote
1 answer

drawAtPoint with rotation

I am having trouble drawing my imageView.image in the correct position using drawAtPoint. In the app I have used CGAffineTransformMakeRotation to rotate the image view, but when I want to save the imageView as part of a merge with others using…
Wez
  • 10,555
  • 5
  • 49
  • 63
1
vote
1 answer

Invalid Summary on NSMutableArray

I would need some expert advice on how to solve this problem. I am doing some crude testing for a new app for the iPad. I create a NSMutableArray (ballPath) in the viewDidLoad of my view controller (it is declared in my .h file) by loading a plist…
Structurer
  • 694
  • 1
  • 10
  • 23
1
vote
2 answers

convertPoint:fromView: works well on the simulator, not on device

I was happy to see this: answer for how to convert point of a subview and it worked perfect for me on the simulator. But for some reason it doesn't work on the device... Can it be that the views positions are differently managed by the device - or…
Lior Frenkel
  • 806
  • 11
  • 25
1
vote
2 answers

Argument labels do not match any available overloads swift

i have a function which draw text on image but issue is when i call this function it gives a error "Argument labels '(_:, _:)' do not match any available overloads" i am new to swift and dont know how to fix func write_text_on_image(drawtext…
Naqeeb
  • 1,121
  • 8
  • 25
1
vote
2 answers

how to set anchorPoint of view to 0.5 , 0.5 to get view in centre of screen? (Not scene)

I want to make my game full screen not with the black bars on both sides and bottom. so I found this code for that and it works for scene and now it's on full screen but the assets are not correctly positioned. Because of the view's coordinates are…
Ramesh Sanghar
  • 174
  • 1
  • 1
  • 19