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
5
votes
3 answers

Changing CGRectMake (x,x,x,x) to a different location such as (y,y,y,y)

I have placed a button in my view using CGRectMake(x,x,x,x), x being the location and size of course. When I rotate the view using -(BOOL)shouldAutoRotate... I want to change the location of the button from what would be the center in portrait mode…
Jack Humphries
  • 13,056
  • 14
  • 84
  • 125
5
votes
1 answer

What's the difference between height and maxY, and width and maxW?

From the Apple Documentation, the maxY of a view is The largest value for the y-coordinate of the rectangle. The maxX of a view is The largest value of the x-coordinate for the rectangle. Also from the Apple Documentation, the width of a view…
user10015343
5
votes
1 answer

CGRectDivide is deprecated in swift 3

As swift 3 says CGRectDivide is deprecated and the replacement is divided(atDistance: CGFloat, from fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect). As I know CGRectDivide was dividing a source rectangle into two component rectangles by…
Termin
  • 151
  • 5
  • 13
5
votes
2 answers

Point inside a rotated CGRect

How would you properly determine if a point is inside a rotated CGRect/frame? The frame is rotated with Core Graphics. So far I've found an algorithm that calculates if a point is inside a triangle, but that's not quite what I need. The frame being…
Dids
  • 569
  • 7
  • 24
5
votes
2 answers

Define CGRectmake with CGPoint and/or CGSize

This is a very simple question of which i can't seem to find the answer. How to do this : CGRectMake(1, 3, size) or CGRectMake(pointB, size) or CGRectMake(pointB, size.width, size.height) instead of CGRectMake(self.someview.frame.origin.x,…
Plot
  • 898
  • 2
  • 15
  • 26
5
votes
2 answers

iOS: Programmatically creating UIWindow results in wrong position

In iOS 5.1.1, I have found that if I create my UIWindow (I'm tired of IB), and set its frame to [UIScreen mainScreen].bounds, the window shows up under the status bar. However if I do the same thing is iOS 6, it appears in the right spot just below…
RRR
  • 51
  • 1
  • 2
4
votes
0 answers

Retrieving a CGRect from a transformed CGContext and apply to a UIView

I am drawing a PDF page into a CGContext. In order to properly draw it, I am applying some transformations to the context. The pdf page rendered rect is smaller than the view's rect. I want to create a third view that has exact same frame as the…
Cezar Signori
  • 586
  • 6
  • 13
4
votes
1 answer

Programmatically resize NSView

I have a main view that is supposed to display several subviews. Those subviews are directly above and below one another (in the z axis) and will drop down (in the y axis) and move up using this code: if (!CGRectIsNull(rectIntersection)) { …
Elbimio
  • 1,041
  • 2
  • 10
  • 25
4
votes
2 answers

UITextField - Multiple Lines

I'm trying to add lines to my UITextField (my code is below), however, when the typer gets to the end of the text field, instead of going to the next line it keeps going on the same line forever! How do I get it to go to the next line?…
Jack
  • 361
  • 1
  • 4
  • 6
4
votes
2 answers

Fill In UIView With Multiple Colors iOS

I'd like to fill in a UIView Background with multiple colors. I want to use it as a status bar of sorts, so if 1/2 the necessary steps are completed, the UIView Background will be 1/2 green and 1/2 red. When the user completes more steps (say…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
4
votes
5 answers

How to get window size in swift (including iPad split screen)

I want to get the window bounds as CGRect object. This is my current code: let screenSize : CGRect = self.view.window?.frame I found this code on the internet, but sometimes screenSize is nil. Is there any other option?
Daisy the cat
  • 372
  • 3
  • 11
4
votes
2 answers

SwiftUI: Drawing rectangles around elements recognized with Firebase ML Kit

I am currently trying to achieve to draw boxes of the text that was recognized with Firebase ML Kit on top of the image. Currently, I did not have success yet and I can't see any box at all as they are all shown offscreen. I was looking at this…
4
votes
1 answer

How to get dimensions and load PDF Page?

I have a single PDF page in Swift Xcode iOS, let page = self.pdfDocument!.page(at: page_index!)! and I wish to get the dimensions of the page. When I create a breakpoint on the code above, I can see just the PDF. How can I get the width and height…
Galen BlueTalon
  • 173
  • 4
  • 20
4
votes
2 answers

How to rotate a CGRect about its centre?

Background: I want to show a label that is rotated 90 degrees clockwise. The rotated label should be in a certain frame that I specify. Let's say (10, 100, 50, 100). I know that I can rotate a view by using CGAffineTransform. I also know that I…
Sweeper
  • 213,210
  • 22
  • 193
  • 313
4
votes
1 answer

What's the difference between UIView's frame.height and frame.size.height?

I don't understand what the difference is in a UIView between frame.height and frame.size.height. Why add size? For example: override func viewDidLoad() { super.viewDidLoad() scrollView.contentSize.height = self.view.frame.height …
alvin123
  • 79
  • 2
  • 8