cgrect

iOS - Get framing of Visible part of UIImage from UIImageView

跟風遠走 提交于 2019-12-10 13:13:52
问题 I am trying to make a transition like APP Tinder. Detail: In Screen One there is a Vertical Rectangular UIImaveView with contentMode = Aspect Fill, so it hides some portion of Image to adujust Aspect Ratio. In Screen Two (Detail Screen) the same image after transition has to to be passed, but the ImageView in Second screen is Square One. I want to make a Morphing kind of Transition in which User should think that the same ImageView from Screen One become square one in Second one without

CGRectContainsRect Not Working

帅比萌擦擦* 提交于 2019-12-09 12:59:51
问题 I'm having problems with this method. I have two rectangles that are obviously contained within each other.(I've even graphed their coordinates manually to make sure.) When I use CGRectContainsRect to compare these two rectangles, it returns false. For the life of me, I have tried everything, scoured the net, and I can't find an answer to this problem. Anyone have any idea why? I've included the values for the CGRects when I debug to show that they are definitely within each other. -(bool

iOS auto adjust label height

拥有回忆 提交于 2019-12-08 09:07:08
问题 I'm using the following code to auto adjust the height of a label in a UITableView. It works the majority of the time, but certain times text is cut off. Is there something wrong with my code, or anything else I need to add? UILabel *textLabel = ((UILabel *)[cell viewWithTag:3]); textLabel.text = text; CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX); CGSize expectedLabelSize = [text sizeWithFont:textLabel.font constrainedToSize:maximumLabelSize lineBreakMode:textLabel.lineBreakMode]; /

iOS: Programmatically creating UIWindow results in wrong position

為{幸葍}努か 提交于 2019-12-07 06:10:45
问题 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 the status bar. CGRect r = [[UIScreen mainScreen] bounds]; self.window = [[UIWindow alloc] initWithFrame: r]; self.detailViewController = [[DetailViewController alloc] init]; self.window.rootViewController = self.detailViewController; [self.window

How to resize a modalViewController with UIModalPresentationPageSheet

主宰稳场 提交于 2019-12-06 13:28:00
问题 I've a modal view controller that I show with UIModalPresentationPageSheet. The problem is that his default size is too large for my content: so I want to resize is frame to adjust in according with my content. Does anyone know a way/trick to do this ? Thanks 回答1: You can't resize a UIModalPresentationPageSheet because its size is not modifable. 回答2: Actually you can resize the view controller that gets presented with UIModalPresentationPageSheet. To do it you need to create a custom view

Distance between two rectangles

杀马特。学长 韩版系。学妹 提交于 2019-12-06 13:13:40
How can I find the distance between two rectangles? Intersects should return 0 in distance. Here's a quick function for calculating distance between two CGRects represented by a CGSize: CGSize CGSizeDistanceBetweenRects(CGRect rect1, CGRect rect2) { if (CGRectIntersectsRect(rect1, rect2)) { return CGSizeMake(0, 0); } CGRect mostLeft = rect1.origin.x < rect2.origin.x ? rect1 : rect2; CGRect mostRight = rect2.origin.x < rect1.origin.x ? rect1 : rect2; CGFloat xDifference = mostLeft.origin.x == mostRight.origin.x ? 0 : mostRight.origin.x - (mostLeft.origin.x + mostLeft.size.width); xDifference =

Detecting collision, during a CAKeyFrameAnimation

折月煮酒 提交于 2019-12-06 09:37:31
Is it possible to detect the collision of two UIImageViews while one is travelling along a path during a CAKeyFrameAnimation? If so how is this done, I have tried multiple methods including checking both the CGRects for collision during the animation - but can't find a suitable method for performing a method during a CAKeyFrameAnimation and trying to detect collision of the path and the UIImageView. You need to get the properties from the presentation layer. It will have the best approximation of information that exists during animation. Access it by view.layer.presentationLayer Look at the

Swift SpriteKit edgeLoopFromRect Issue

浪尽此生 提交于 2019-12-06 06:14:31
问题 The following code recognizes the bottom and top edges of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough force is applied. It is as if the edges of the scene are beyond the edges of the iphone simulator window. import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView){ self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self

Keep UIView inside Circle Objective-C

醉酒当歌 提交于 2019-12-06 02:55:46
How can I have my Color Selector ( UIView ) to stay inside a color wheel that's 300px 300px? Im using the UIPanGestureRecognizer to drag the Color Selector around the color wheel UIImageView . The diameter of the color wheel is 300px. Here is the image of my UIViewController : The problem is that it can be dragged anywhere outside the wheel: So how can I keep my UIView that hovers over the color wheel say inside the circle? Your help is appreciated. This really seems like more of a math question. If you want to simply prevent the subview from leaving the circle then you need to insert some

Resize UICollectionView Height

旧时模样 提交于 2019-12-05 20:38:21
问题 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