cgrect

Why is there a difference between CGRectInfinite and a CGRect with all members set to INFINITY?

不问归期 提交于 2019-12-12 03:31:05
问题 When working with (contentless) SpriteKit nodes I bumped into an infinite rectangle NSLog(@"%@", NSStringFromCGRect([node calculateAccumulatedFrame])); which outputted {{inf, inf}, {inf, inf}} I thought to check for this with CGRectIsInfinite , but that test failed, which lead me to trying the following check CGRect rect = [node calculateAccumulatedFrame]; if (rect.origin.x == INFINITY && rect.origin.y == INFINITY && rect.size.width == INFINITY && rect.size.height == INFINITY) { if (

Change width to a IBOutlet (UIImageView)

我们两清 提交于 2019-12-12 02:46:36
问题 I was doing some experiments with Xcode an a little question comes to my mind: that is how I could change size of an UIImage created by storyboard. below the code I used: @IBOutlet var label: UILabel! @IBOutlet var img: UIImageView!//x=0, y=0, w=50, h=50, red, created in the storyboard var numero = 11 override func viewDidLoad() { super.viewDidLoad() if numero < 10 { label.text = "\(numero)" img.backgroundColor = UIColor.blueColor() } else if numero > 10 { label.text = "\(numero)" img.frame =

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

安稳与你 提交于 2019-12-12 02:07:13
问题 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 method, I have been able to generate a series of small circles (dots) along a circular arc (uber circle). Each dot is centred on the perimeter of the uber circle (as shown below). In order to label each dot I use

iOS size table row based on content in textView

只愿长相守 提交于 2019-12-12 00:48:09
问题 I am trying to size a row in my table to the height of a textView so that the user does not have to scroll the textView, but rather scrolls the table. What I have implemented so far seems to work most of the time although sometimes the row height is a little too small, forcing the user to scroll the textview a little, or the row height is too much create a lot of whitespace after the text ends. How can I frame it just right? Code: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear

UIGraphicsGetImageFromCurrentImageContext crop to content and not to bounding box

半腔热情 提交于 2019-12-12 00:02:26
问题 I have an area where a user can add their signature to an app, to verify an order. They sign with their touch. The only thing is, the frame for the signature is large, and if the user were to make a signature very small, when I save the image, I'm left with a wealth of empty space around the image, which, when I add it to an email further down the process can look horrible. Is there any way, using that I can crop the image to whatever the bounds of the actual content is, and not the bounds of

UIView absolute screen point

▼魔方 西西 提交于 2019-12-11 20:25:12
问题 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 that is a child of another view controller repeating to the fifth or sixth view controller. And due to this complex design I need the absolute rect of the UIButton so I can display an UIActionSheet on the "main"

Find UILabel bottom position so a second UILabel can be created below

匆匆过客 提交于 2019-12-11 05:38:04
问题 I have a new article that I am creating. A UILabel is being added for the article title. The title text sometimes might be one, two or three lines of text. I then need to create a UILabel below the title. I am having trouble positioning the date UILabel since the title has a dynamic height. Is there a calculation to get the bottom position of my UILabel 's frame? Note: I am using siteToFit to make sure the UILabel 's frame fits. // Text UILabel *title = [[UILabel alloc] initWithFrame

Getting Visible Rect of UIView

时光毁灭记忆、已成空白 提交于 2019-12-11 03:35:47
问题 What's the simplest method to get the visible rect of any arbitrary UIView as a CGRect , assuming that the UIView is only clipped along the edges (no other views breaking it up somewhere in the middle)? For clarity, this method should not only retrieve the visible rect relative to the view's superview. But relative to all it's ancestors at a minimum and ideally relative to all siblings as well. 回答1: Try this! CGRect visibleRect = CGRectIntersection(self.frame, superview.bounds); 来源: https:/

Simple way to display the borders of a CGRect?

无人久伴 提交于 2019-12-10 22:43:15
问题 I'm trying to find a way to display the borders of some CGRect s in my iOS program for debugging purposes. Is there a fairly simple way to do this? I just need to see where the program is creating these rectangles, so I can track down some odd touch behaviors (or lack thereof). My class init method: // Initialize with points and a line number, then draw a rectangle // in the shape of the line -(id)initWithPoint:(CGPoint)sP :(int)w :(int)h :(int)lN :(int)t { if ((self = [super init])) { startP

Accessing CGRect values directly vs normalizing them in Swift - Objective-C rules still valid?

ⅰ亾dé卋堺 提交于 2019-12-10 16:43:06
问题 This question is inspired by Andrew Carter's comment on a previous question about the new CGSize initializer in Swift. The Apple Docs for CGGeometry say: ... your applications should avoid directly reading and writing the data stored in the CGRect data structure. Instead, use the functions described here to manipulate rectangles and to retrieve their characteristics. Is Apple's recommendation to not directly access the data in a CGRect still valid with Swift? Why should CGRectGetMidX ,