cgrect

How to get frame size after autoresize is done

本秂侑毒 提交于 2019-12-04 06:58:13
I wonder, how and when (viewDidLoad, viewWillAppear, viewDidAppear) can I get a UIViews frame size that was autoresized to fit its partent view? Rog It's not clear from your question why you want it but I imagine it is to layout your sub views. Luckily Apple knew you would want to do that and implemented -(void)layoutSubViews see this: When is layoutSubviews called? I tried layoutSubviews , but it gets called more than once which is a problem when I need the auto sized frame in order to create a CGContext to draw into. The solution I used was to expose an init method on my custom UIView for

Make view cover full screen using CGRectMake

自古美人都是妖i 提交于 2019-12-04 04:04:35
问题 I'm creating a view (using card.io), and I want the view to cover the full screen. Its only covering about 2/3rds of the screen atm. Heres the code: CardIOView *cardIOView = [[CardIOView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)]; Here is an example 回答1: Dave from card.io here. When you create a CardIOView , its frame will take on whatever size you set. However, the camera view within the (transparent) CardIOView will have the standard iOS

Resize UICollectionView Height

佐手、 提交于 2019-12-04 03:48:28
I'm trying to resize a UICollectionView height by setting it to 0 when the view controller is loaded, then increasing its size with an animation when a button is pressed. I've tried a few different things but it doesn't change in size at all. Here's all the different things I've tried to change its height to 0: CGRect bounds = [self.collectionView bounds]; [self.collectionView setBounds:CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height - 100)]; .... CGRect frame = [self.collectionView frame]; [self.collectionView setFrame:CGRectMake(frame.origin.x, frame.origin

Convert CGPoint from CGRect to other CGRect

懵懂的女人 提交于 2019-12-04 03:32:51
问题 I have placed one label on view and view's frame is CGRectMake(0,0,270,203) . Now I have to take screen shot of view with CGRectMake(0,0,800,600) . So I have to convert label from old rect to new rect . here is code which I used to take screen shot: CGRect rect = [view bounds]; UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f); CGContextRef context = UIGraphicsGetCurrentContext(); [view.layer renderInContext:context]; UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext

Set background color for only part of UIView

爱⌒轻易说出口 提交于 2019-12-04 01:14:18
I want the bottom (not quite half) of my UIView to be a different color than the top. I'm wondering if I should create a CGRect and then color that? Is this along the right track? - (void)drawRect:(CGRect)rect { CGRect aRect = CGRectMake(x, y, width, height); // Fill the rectangle with grey [[UIColor greyColor] setFill]; UIRectFill( rect ); } Yes, as you are already overriding drawRect method, this will do. - (void)drawRect:(CGRect)rect { CGRect topRect = CGRectMake(0, 0, rect.size.width, rect.size.height/2.0); // Fill the rectangle with grey [[UIColor greyColor] setFill]; UIRectFill( topRect

Crop area different than Selected Area in iOS?

若如初见. 提交于 2019-12-03 16:10:10
Here is link on github https://github.com/spennyf/cropVid/tree/master to try it out your self and see what I am talking about it would take 1 minute to test. Thanks! I am taking a video with a square to show what part of vid will be cropped. Like this: Right now I am doing this of a piece of paper with 4 lines in the square, and half a line difference on top and bottom. And then I crop the video using code I will post, but then when I display the video I see this (Ignore background and green circle): As you can see there are more than four lines, so I am setting it to crop a certain part but

Point inside a rotated CGRect

前提是你 提交于 2019-12-03 15:41:25
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 rotated is a regular UIView with a few subviews. Let's imagine that you use transform property to rotate a view: self.sampleView.transform = CGAffineTransformMakeRotation(M_PI_2 / 3.0); If you then have a gesture recognizer, for example, you can see if the user tapped in that location using locationInView with the rotated view, and it automatically

Turn two CGPoints into a CGRect

▼魔方 西西 提交于 2019-12-03 09:20:40
问题 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 ? 回答1: This will take two arbitrary points and give you the CGRect that has them as opposite corners. CGRect r = CGRectMake(MIN(p1.x, p2.x), MIN(p1.y, p2.y), fabs(p1.x - p2.x), fabs(p1.y - p2.y)); The smaller x value paired with the smaller y value will always be the origin of the rect (first two arguments). The

Changing CGrect value to user coordinate system

情到浓时终转凉″ 提交于 2019-12-03 08:16:12
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 Advance. To convert a rectangle from a coordinate system that has its origin at the bottom left (let's just call it traditional coordinate system to give it name) to a system where the origin is at the top left (iPhone coordinate system) you need to know the size of the view where the CGRect is, since the view is the reference for the rectangle. For

Subtract CGRect from CGRect — largest piece of one not containing the other

假如想象 提交于 2019-12-03 05:20:32
How I can substract one CGRect from another? I want the result R1 - R2 to be the largest subrectangle of R1 that does not intersect R2. Example 1 : +----------------------------------+ | +--------+ | | | R2 | | | | | | | +--------+ R1 | | | | | | | +----------------------------------+ R3 = CGRectSubstract(R2,R1); +----------------------+ | | | | | | | R3 | | | | | | | +----------------------+ Example 2 : +-----------------------+----------+ | | | | | R2 | | | | | R1 +----------+ | | | | | | +----------------------------------+ R3 = CGRectSubstract(R2,R1); +-----------------------+ | | | | | |