Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use cgsize make?

Tags:

ios

cgsize

I have been trying to use cgsizemake as follows:

I'm trying to make the frame of my image a different size using cgrectmake instead of changing the coordinates.

So far I have tried

 maincharacter.frame = cgsizemake (14, 14); 

but I keep getting the error

assigning to cgrect from incompatible type CGsize

like image 281
jwhyyou Avatar asked Apr 26 '14 05:04

jwhyyou


3 Answers

One solution would be:

CGRect frame = maincharacter.frame;
frame.size = CGSizeMake(14, 14);
maincharacter.frame = frame;
like image 195
rmaddy Avatar answered Nov 15 '22 06:11

rmaddy


CGSize only accepts height and width

CGSize c=CGSizeMake(width, height);

If you want to set the frame size use CGRectMake

maincharacter.frame=CGRectMake(x-origin,y-origin, width, height);
like image 41
Mayank Jain Avatar answered Nov 15 '22 07:11

Mayank Jain


maincharacter.frame must return (x, y, width, height) 4 parameters and CGSizeMake only have "width" and "height" 2 parameters. So You got an error. The solution is use frame.size, which returns 2 parameters to work with CGSizeMake(14, 14).

like image 1
user2239950 Avatar answered Nov 15 '22 06:11

user2239950