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
10
votes
1 answer

AVCaptureMetadataOutput().rectOfInterest not Working

I am building a UIView that has an overlaid box and the end-goal is to have the QR Code reader only fire when the QR falls within the box. I know that I need to set the .rectOfInterest() to be the same as the yellow box, but in the current…
Caleb Rudnicki
  • 345
  • 8
  • 17
10
votes
1 answer

CGRect.offsetBy Not Working

How do I rewrite the code below? self.view.frame = CGRectOffset(self.view.frame, 0, movement) 'Offset' has been replaced by 'offsetby' When I replaced it with the so called "solution": self.view.frame = CGRect.offsetby(self.view.frame, 0,…
bigkurtdirt49
  • 121
  • 1
  • 5
10
votes
2 answers

Making a triangle in a UIView with a CGRect Frame

HI I am making a game and need a spike at the bottom which I have decided to do via a UIView and collisions. I am coding in swift. I currently have a square: //Object Setup let square = UIView(frame: CGRect(x:100, y:100, width: 100,…
Zog
  • 1,094
  • 2
  • 11
  • 24
10
votes
3 answers

Crop image to a square according to the size of a UIView/CGRect

I have an implementation of AVCaptureSession and my goal is for the user to take a photo and only save the part of the image within the red square border, as shown below: AVCaptureSession's previewLayer (the camera) spans from (0,0) (top left) to…
swiftcode
  • 3,039
  • 9
  • 39
  • 64
10
votes
3 answers

Proper transform for scaling a UIView from a rect?

I want to mimic "zooming in" on a view. The larger view will be added as a subview to the smaller view's superview, and the larger view should look as if it is zooming in from the smaller view. Given the rect of the smaller view fromRect and the…
akaru
  • 6,299
  • 9
  • 63
  • 102
9
votes
2 answers

MonoTouch convert color UIImage with alpha to grayscale and blur?

I am trying to find a recipe for producing a a blurred grayscale UIImage from a color PNG and alpha. There are recipes out there in ObjC but MonoTouch does not bind the CGRect functions so not sure how to do this. Any ideas? Here is one ObjC…
Sheldon Hage
  • 414
  • 3
  • 8
9
votes
5 answers

iOS CGRect is inside another CGRect

Anyone has a good solution for the following task? I need to check if a CGRect is inside another CGRect and return a CGPoint, that gives the offset if the rect window is outside in any dimension from the containing. thanks in advance
Bence Pattogato
  • 3,752
  • 22
  • 30
9
votes
2 answers

How to combine CGRects with each other in Swift

I was wondering if there was any way to combine a CGRect with another CGRect to get a new CGRect. Does swift have any preset functionality to do this or is there another way of achieving this?
Zouvv
  • 143
  • 1
  • 8
9
votes
6 answers

can a particular rect of UIview have different alpha..?

I wan't a imageview which is semi-transparent in other parts and completely transparent in the middle .. see this image.. i have managed to do it but it is not the best of ways.. can I only have a rect inside yellow lines transparent ...? EDIT: Is…
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
9
votes
2 answers

iOS function says "CGRectMinY" which should be bottom left corner

According to the Apple documentation, CGRectMinY(CGRect) rect returns the y coordinate of the top right corner of the specified rectangle Shouldn't it be the bottom left corner of the rectangle? Because I think the Y-axis is downwards.
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
8
votes
1 answer

Changing CGrect value to user coordinate system

I have a CGRect; can I transfer its coordinates to be in the user coordinate system, i.e., bottom left corner to top instead of top left corner to bottom. Is there any predefined method for this or do I need to calculate it manually? Thanks in…
ajay
  • 3,245
  • 4
  • 31
  • 59
8
votes
0 answers

what exactly does CG_NUMERICS_SHOW_BACKTRACE do

In my project I'm getting a lot of crashes for CALayerInvalidGeometry; CALayer bounds contains NaN: but I am not able to reproduce the crash and only pick it up in Fabric so it's not possible to share the code here as I can't upload my entire…
user1898829
  • 3,437
  • 6
  • 34
  • 62
8
votes
1 answer

Uncaught exception: CALayer position contains NaN when doing animation

I am getting this error in my application when I run on an iPad: Uncaught exception: CALayer position contains NaN The same code works fine on an iPhone. - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { …
Hemang
  • 26,840
  • 19
  • 119
  • 186
8
votes
1 answer

How to set text color when using drawInRect?

I have been using PaintCode to draw some of the graphics within my app, some of the drawn elements have text that is drawn using "drawInRect". The text is always showing up black regardless of what I do to try and set the color. here is the code…
Nathan
  • 1,609
  • 4
  • 25
  • 42
8
votes
2 answers

Objective-c: How to rotate CGRect

I've tried to rotate my rectangle, but it does not work properly. Here is part of my code, I found it in another post: #define DEGREES_TO_RADIANS(x) (M_PI * x / 180.0) -(void)drawRect:(NSRect)rect { CGContextRef cRef = [[NSGraphicsContext…
YU FENG
  • 888
  • 1
  • 12
  • 29
1 2
3
47 48