Questions tagged [cgrect]

CGRect is a structure from the ApplicationServices framework used with Apple's OSX and iOS operating systems. This structure is used to represent the origin and size of a rectangle.

CGRect is a structure that contains the location and dimensions of a rectangle.

Fields

  • origin: A point that specifies the coordinates of the rectangle’s origin.
  • size: A size that specifies the height and width of the rectangle.
716 questions
4
votes
2 answers

why UITextView draws text in bad frame after resizing?

I'm stuck with some kind of magic: when I try to change UITextView frame (in this case with UISlider), text is drawn in some other (smaller) area than frame (resizing multiple times). The funny thing is that if we slide fast enough when trying to…
Povilas
  • 445
  • 3
  • 17
4
votes
1 answer

How to get a tapering line brush effect in Objective C using GraphicContext

I am doing a calligraphy application and would like to modify my code below so when a user ends a brush stroke, the line tapers and thins out like it would with a real calligraphy pen (a flick effect). I understand that touchesEnded may be a better…
AppleFanBoy
  • 101
  • 1
  • 1
  • 8
4
votes
2 answers

CGRect in Pixels?

Pretty much I want to properly have the size of a button in my app converted to the amount of pixels for its width and height. So lets say it has a width of 50 and a height of 100, on a retina display device I want it to return a width of 100 and a…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
4
votes
2 answers

Check for overlapping views after transform

I have multiple UIImageView's within a UIView. These UIImageViews have been transformed. When the gesture is applied to any one of the UIImageView's the overlapping imageViews should get displaced in such a way that the move outside the…
Nayan Chauhan
  • 542
  • 5
  • 16
4
votes
4 answers

Cannot change UIView frame size

I have a custom uiview that i am trying to update the frame size. I do it like this in a method once it is clicked. The method is called, and the frame value changes, however on the screen nothing happens! if (!touched) { GameBox *box =…
michaela
  • 173
  • 1
  • 2
  • 13
3
votes
1 answer

amount of rect intersection?

i am trying to check the degree of overlap between 2 CGPaths. the easiest way i have come up with is get the percentage of the overlap between the bounding CGRects. I know this will fail when different paths occupy similar bounds. but oh well, if…
Lordof Theflies
  • 301
  • 1
  • 6
  • 16
3
votes
1 answer

"Static method 'buildBlock' requires that 'CGRect' conform to 'View'"

My Code looks something like this: import SwiftUI struct MainView: View { var body: some View { CGRect(x: 20, y: 20, width: 100, height: 100) } } However, I get the error: Static method 'buildBlock' requires that 'CGRect' conform…
Johnas
  • 296
  • 2
  • 5
  • 15
3
votes
2 answers

Get CGRect of View

I'm using a "RectGetter" to get the CGRect of a View. Like this: Text("Hello") .background(RectGetter(rect: self.$rect)) struct RectGetter: View { @Binding var rect: CGRect var body: some View { GeometryReader { proxy in …
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
3
votes
2 answers

Problem while storing CGRect into plist

I am trying to save an array which contains CGRect values. I know plists are not compatible with the CGRect type, so I slightly modified my code and now I am storing NSNumber instead of storing the rect value -- I split the rect value into four…
ajay
  • 3,245
  • 4
  • 31
  • 59
3
votes
3 answers

How to convert CGRect to CGPoint iOS Swift

Here i want to convert UIImageView's maxY CGRect value to CGPoint, but when i tried to convert CGRect value to CGPoint i got an error. Code let cgPoint = imgPin.convert(imgPin.frame.minY, to: self.view) Error Expression type '@lvalue CGRect'…
steveSarsawa
  • 1,559
  • 2
  • 14
  • 31
3
votes
0 answers

How to transform a scaled CGRect to effectively crop the visible CGRect?

My problem is simple, but I'm having a hard time with the actual code. I'm using a camera (ARCamera from ARKit) that displays the video feed onto the screen. The iPhone camera is wide (camera space), whereas the screen only shows part of it (screen…
xta
  • 729
  • 2
  • 8
  • 29
3
votes
2 answers

Swift iOS -How to get frame of button inside cell's superView

I have collectionView inside a view controller. Inside the collectionView cell I have a button. Since there will be several cells each button will have a different location inside the vc. When a button is tapped, how can I get the frame of the…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
3
votes
1 answer

In Swift, why does .zero fill the entire window in this example?

I'm following a tutorial on creating a WKWebView within a view controller and the WKWebView is instantiated with a CGRect value of .zero but the website opens to the entire size of the view controller when I run this code: import Foundation import…
Laurence Wingo
  • 3,912
  • 7
  • 33
  • 61
3
votes
3 answers

How to change x and y of CGRect?

I draw a rectangle. When I touch screen, I can change width and height. By default I make x = 50, y = self.view.frame.height/2. I need to stretch rectangle relative to x and y. How can I change x and y? var scanRectangleRect = CGRect.zero var…
kvv
  • 85
  • 2
  • 8
3
votes
2 answers

iOS Swift Setting View Frame Position Programmatically

I having two sub views inside scrollview. I need to position that both subviews programmatically. I did it correctly by writing code inside DispatchQueue.main.async. Here is the code: DispatchQueue.main.async { self.SelectClientDetailView.frame…
Kavin Kumar Arumugam
  • 1,792
  • 3
  • 28
  • 47