Questions tagged [cgrectmake]

CGRectMake is used in iOS, it returns a rectangle with the specified coordinate and size values.

CGRectMake is used in iOS (), it returns a rectangle with the specified coordinate and size values.

CGRect CGRectMake (
  CGFloat x,
  CGFloat y,
  CGFloat width,
  CGFloat height
);
  • x: The x-coordinate of the rectangle’s origin point.
  • y: The y-coordinate of the rectangle’s origin point.
  • width: The width of the rectangle.
  • height: The height of the rectangle.
153 questions
79
votes
4 answers

How to initialize properties that depend on each other

I want a picture to move to the bottom. If I press a button the pic should move down by 1. I added the picture and a button: var corX = 0 var corY = 0 var runter: UIButton = UIButton.buttonWithType(UIButtonType.System) as UIButton var image =…
Lukas Köhl
  • 1,569
  • 2
  • 15
  • 28
54
votes
3 answers

Update CGRectMake to CGRect in Swift 3 Automatically

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…
yonasstephen
  • 2,645
  • 4
  • 23
  • 48
53
votes
4 answers

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

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.
inorganik
  • 24,255
  • 17
  • 90
  • 114
47
votes
9 answers

iOS frame change one property (eg width)

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…
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
33
votes
1 answer

How do I get the current x and y position so that I can use GCRectMake?

I have this code inside an animation: image.frame = CGRectMake(x: x, y: y, width, height) I need to get the x and y coordinates of an image. I found this Objective-C code: CGPoint origin = imageView.frame.origin; Once I find the x and y position…
Cesare
  • 9,139
  • 16
  • 78
  • 130
29
votes
1 answer

CGRectZero vs CGRect.zeroRect?

Both seem to work the same in Swift. Which should we use? CGRectZero vs CGRect.zeroRect GRectMake(1, 1, 1, 1) vs CGRect(x: 1, y: 1, width: 1, height: 1) UIEdgeInsetsMake(1, 1, 1, 1) vs UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) Other…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
26
votes
4 answers

Check if CGRect null in getter

I am trying to check if a CGRect is null in my property getter and if it is, load a value by default, however, in my init method, when I use the property, it returns zero for all values. Here is my getter: - (CGRect)frame { …
crizzwald
  • 1,037
  • 2
  • 14
  • 30
18
votes
9 answers

How can I speed up a UITableView?

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…
Luke
  • 7,110
  • 6
  • 45
  • 74
6
votes
3 answers

CGRect positioning according to center point

I'm trying to create multiple views for an iPad app. First I created a menu view and then a sub-menu view with coordinates according to menu. So it looks like this: What I did: self.view = [[UIView alloc]…
diogocarmo
  • 960
  • 1
  • 11
  • 30
6
votes
3 answers

CGRectMake alternative

I have seen this alternative to using CGRectMake() in order to initialise a CGRect variable: CGRect frame = (CGRect){0,0,10,10}; My question is, how does CGRect frame = (CGRect){0,0,10,10}; work? What's going on behind the scenes? It looks like a…
Barjavel
  • 1,626
  • 3
  • 19
  • 31
5
votes
1 answer

SetFrame works on iPhone, but not on iPad. Auto resize mask to blame?

I'm trying to resize a UITextView when the keyboard shows. On iPhone it works beautifully. When the the system dispatches a keyboard notification, the text view resizes. When it's done editing, I resize it to fill in the initial space. (Yes, I'm…
Moshe
  • 57,511
  • 78
  • 272
  • 425
5
votes
5 answers

iPhone programming: How do I make a UIImage in a UIImageView show at actual size?

I have a UIImage that I want to show pixel-for-pixel on an iPhone 4/4S/5 screen. It's important that it is not scaled at all, but when I try using setImage, it makes the image too large. My UIImageView is made in a UIStoryboard (since I'm really new…
sudo
  • 5,604
  • 5
  • 40
  • 78
5
votes
2 answers

Define CGRectmake with CGPoint and/or CGSize

This is a very simple question of which i can't seem to find the answer. How to do this : CGRectMake(1, 3, size) or CGRectMake(pointB, size) or CGRectMake(pointB, size.width, size.height) instead of CGRectMake(self.someview.frame.origin.x,…
Plot
  • 898
  • 2
  • 15
  • 26
4
votes
2 answers

Make view cover full screen using CGRectMake

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,…
spogebob92
  • 1,474
  • 4
  • 23
  • 32
4
votes
2 answers

how to set height of UILabel based on the text we have

I have UILabel of width 260 where I have long text (maybe around 1000 characters). I wanted to set the height of the UILabel based on the content. Sometimes I can have 100 chars, sometimes I can have 1000 chars). Based on text, how can I set the…
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
1
2 3
10 11