cgrectmake

How do I create a CGRect from a CGPoint and CGSize?

久未见 提交于 2019-12-03 05:28:32
问题 I need to create a frame for a UIImageView from a varying collection of CGSize and CGPoint , both values will always be different depending on user's choices. So how can I make a CGRect form a CGPoint and a CGSize ? Thank you in advance. 回答1: Two different options for Objective-C: CGRect aRect = CGRectMake(aPoint.x, aPoint.y, aSize.width, aSize.height); CGRect aRect = { aPoint, aSize }; Swift 3: let aRect = CGRect(origin: aPoint, size: aSize) 回答2: Building on the most excellent answer from

How do I create a CGRect from a CGPoint and CGSize?

江枫思渺然 提交于 2019-12-02 17:51:34
I need to create a frame for a UIImageView from a varying collection of CGSize and CGPoint , both values will always be different depending on user's choices. So how can I make a CGRect form a CGPoint and a CGSize ? Thank you in advance. Two different options for Objective-C: CGRect aRect = CGRectMake(aPoint.x, aPoint.y, aSize.width, aSize.height); CGRect aRect = { aPoint, aSize }; Swift 3: let aRect = CGRect(origin: aPoint, size: aSize) Building on the most excellent answer from @Jim, one can also construct a CGPoint and a CGSize using this method. So these are also valid ways to make a

UIView resizing but not the SubViews

天大地大妈咪最大 提交于 2019-12-02 03:27:50
问题 I have an UIView (v1): --------------- | --------- | | | | | | | | | | | | | | | UIImage | | | | View | | | --------- | | UIView | --------------- With an UIImageView (img1) as subview. When I'm going to resize the UIView: int img1int = v1.frame.size.height+(img1.frame.size.height - img2.frame.size.height); v1.frame = CGRectMake(v1.frame.origin.x, v1.frame.origin.y, v1.frame.size.width, img1int+20); The image resize with the view, but I want to just resize the view, and let the image with the

UIView resizing but not the SubViews

这一生的挚爱 提交于 2019-12-02 02:16:29
I have an UIView (v1): --------------- | --------- | | | | | | | | | | | | | | | UIImage | | | | View | | | --------- | | UIView | --------------- With an UIImageView (img1) as subview. When I'm going to resize the UIView: int img1int = v1.frame.size.height+(img1.frame.size.height - img2.frame.size.height); v1.frame = CGRectMake(v1.frame.origin.x, v1.frame.origin.y, v1.frame.size.width, img1int+20); The image resize with the view, but I want to just resize the view, and let the image with the normal height . The int is a calculus that I made, for the UIView has its height related to the height

Make view cover full screen using CGRectMake

人走茶凉 提交于 2019-12-01 18:52:48
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 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 camera form factor of 4:3. So if the CardIOView is 320 points wide, then its camera view will be ~426 points

How can I speed up a UITableView?

依然范特西╮ 提交于 2019-11-29 19:28:13
I have a UITableView with about 400 cells in 200 sections and it's a little sluggish in responding to user interaction (scrolling, selecting cells.) I've made sure the methods for retrieving cells and header views do the bare minimum as it's running, and I don't think I'm doing anything out of the ordinary to make it slow. The cells and headers just have a background image and text. Has anyone else had this kind of problem, and do you know any way to make it run a little faster? Edit: I'm offering a bounty because I'd love to get some useful feedback on this. I don't think the answer lies in a

Update CGRectMake to CGRect in Swift 3 Automatically

佐手、 提交于 2019-11-28 21:01:17
Now that CGRectMake , CGPointMake, CGSizeMake, etc. has been removed in Swift 3.0, is there any way to automatically update all initializations like from CGRectMake(0,0,w,h) to CGRect(x:0,y:0,width:w,height:h) . Manual process is.. quite a pain. Not sure why Apple don't auto convert this when I convert the code to Current Swift Syntax... Apple actually does provide this feature. All you have to do is go to: Edit > Convert > To Latest Swift Syntax... And then follow the onscreen prompts. This will solve your syntax issues and you won't have to make new functions for all of the various removed

iOS frame change one property (eg width)

人盡茶涼 提交于 2019-11-28 20:06:15
This question was originally asked for the objective-c programming language. At the time of writing, swift didn't even exist yet. Question Is it possible to change only one property of a CGRect ? For example: self.frame.size.width = 50; instead of self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, 50); of course I understand that self.frame.size.width is read only so I'm wondering how to do this? CSS ANALOGY proceed at your own risk for those of you who are familiar with CSS , the idea is very similar to using: margin-left: 2px; instead of having to change

How can I speed up a UITableView?

♀尐吖头ヾ 提交于 2019-11-28 14:57:51
问题 I have a UITableView with about 400 cells in 200 sections and it's a little sluggish in responding to user interaction (scrolling, selecting cells.) I've made sure the methods for retrieving cells and header views do the bare minimum as it's running, and I don't think I'm doing anything out of the ordinary to make it slow. The cells and headers just have a background image and text. Has anyone else had this kind of problem, and do you know any way to make it run a little faster? Edit: I'm

Update CGRectMake to CGRect in Swift 3 Automatically

帅比萌擦擦* 提交于 2019-11-27 13:24:13
问题 Now that CGRectMake , CGPointMake, CGSizeMake, etc. has been removed in Swift 3.0, is there any way to automatically update all initializations like from CGRectMake(0,0,w,h) to CGRect(x:0,y:0,width:w,height:h) . Manual process is.. quite a pain. Not sure why Apple don't auto convert this when I convert the code to Current Swift Syntax... 回答1: Apple actually does provide this feature. All you have to do is go to: Edit > Convert > To Latest Swift Syntax... And then follow the onscreen prompts.