4GetFullOf 4GetFullOf - 3 months ago 22
iOS Question

Only changing X axis value

Im aware I can change the position of my image view like this

myImageView.frame = CGRectMake(99, 34, 32, 32);


But how do I change just the x value leave the rest as they are?
I realize this is a simple question but because I don't know how to word the search Im having difficulty finding a solution. Thanks

Answer Source
//capture frame
CGRect thisRect = myImageView.frame;

//modify required frame parameter (.origin.x/y, .size.width/height)
thisRect.origin.x = 0;

//set modified frame to object
[myImageView setFrame:thisRect];