FAQ Database Discussion Community


Limit characters by UITextView height

ios,swift,uitextview,cgrect
Using the following code I'm attempting to limit the height of my UITextView by disallowing the user to enter characters once the UITextView is beyond a certain content size. But the problem is that with the current code, the last character after the height limit is written anyway such that...

When trying to get dynamically created UILabel to wrap, text disappears

xcode,swift,word-wrap,cgrect,sizetofit
I'm trying to display some description text that varies from a couple of words to a hundred words. I've set my UILabel to wrap to compensate using the code below descText.frame = CGRect(x: 115, y: 160, width: 465, height: 21) descText.textAlignment = NSTextAlignment.Left descText.numberOfLines = 0 descText.lineBreakMode = NSLineBreakMode.ByWordWrapping descText.sizeToFit()...

CGRect with empty values?

ios,objective-c,cgrect
I generate my Views in my View Controller like this now: -(void) generateCardViews { int positionsLeftInRow = _CARDS_PER_ROW; int j = 0; // j = ROWNUMBER (j = 0) = ROW1, (j = 1) = ROW2... for (int i = 0; i < [self.gameModel.cards count]; i++) { NSInteger value =...

iOS CGRect is inside another CGRect

ios,uiview,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...

How can i set Frame properly After dragging?

ios,uibutton,uipangesturerecognizer,cgrect,cgpoint
I am Building iOS App Using StoryBoards. In My App, I want to create a custom slider. For that I created two views and image programmatically. Big View is considered as slider. And small one means the thumb.I applied panGesture for the thumb so that it can be moveable. It...

CGRectContainsPoint fails in iOS

ios,objective-c,iphone,cgrect
I am using CGRectContainsPoint to find whether a point is inside a rect but it always returns false. If I am wrong please correct me and help me understand whether the point is inside the CGRect. Here is my code: BOOL isObjectInside = false; CGPoint serverPoint = CGPointMake(78,157); CGRect frame...

How to check if titleLabel of UIButton exceeds button's frame?

ios,objective-c,uibutton,cgrect
What's the best way to check whether the titleLabel's text of a UIButton is so long that it actually exceeds the size of the button to prevent situations like the one in the screenshot below? I am used to doing this with UILabel and setting the properties minimumScaleFactor and adjustsFontSizeToFitWidth,...

text labels drawn in CGRect form an elliptical arc when images drawn using the same coordinates form a circular arc

ios,objective-c,cgrect
I am new to Core Graphics and trying to understand why text labels I draw in CGRect form an elliptical arc when images I draw using the same coordinates form a circular arc. The original code by Arthur Knopper creates circles wherever the screen is touched. By removing the touches...

apple swift how to change CGRect(x: 400, y:500 , to a stored varable

swift,cgrect
hi im righting a function to animate something I'm passing it a UIImageView (i shall be passing it the x and y once i sort this bit out) how do i change the CGRect(x: 400, y:500 if i change CGRect(x: 400, y:500 to CGRect(x: xdis, y:ydis i get build fail...

Creating a CGRect as an Associated Object?

ios,objective-c,uibutton,cgrect,associated-object
I'm attempting to create a CGRect property for my UIButton's as an associated object, so that I don't have to subclass UIButton just for this. Basically I'm adding a property titled, tapArea, and I'm having trouble creating it. This is what I have so far: @dynamic tapArea; - (void)setTapArea:(CGRect)tapArea {...

Swift SpriteKit edgeLoopFromRect Issue

ios,swift,sprite-kit,cgrect,skphysicsbody
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...

Determine rotation of a UIView in Swift

ios,swift,rotation,cgaffinetransform,cgrect
Is there a way to determine how far a UIView has been rotated in Swift? For example, the UIView is rotated by the user using a rotation gesture recognizer, and then later, outside the gesture recognizer callback function, I want to determine how many degrees (or radians) the UIView was...

Swift: Set UIButton Image with CGRect

ios,swift,uibutton,cgrect,uigraphicscontext
I'd like to set the image of a UIButton, but without creating all of the assets at different sizes. Since it should be just a grey rectangle, with some text on top, I'm trying to do this by creating a CGRect. The title is displayed as desired, and the button...

Make a UIView stick to bottom of the ViewController frame in Swift

ios,swift,uiview,cgrect
I have created a UIView (it's just a blue rectangle) and I want it to stick to the bottom of the frame/view of the screen. var nextBar = UIView() nextBar.backgroundColor = UIColor(red: 7/255, green: 152/255, blue: 253/255, alpha: 0.5) nextBar.frame = CGRect(x: 0, y: 600, width: self.view.frame.width, height: 50) self.view.addSubview(nextBar)...

UIView absolute screen point

ios,objective-c,uiview,cgrect
Is there an easy way of getting the absolute point of UIView? By absolute I mean the location of the UIView relative to 1024x768 on an iPad? I need an easy way because I have a UIButton inside a UITableViewCell inside a UITableView inside a view presented by a viewcontroller...

Get position of UIButton in UITableViewCell

ios,objective-c,uitableview,cgrect
I have a button in a static UITableViewCell. What I want to do is place a UIView at the buttons location. If I just get the buttons position, it will give me a position relative to the tableviews cell, not from the top of the tableViewController. What I want is...