Skip to content

Instantly share code, notes, and snippets.

@keicoder
Created March 3, 2014 09:47
Show Gist options
  • Save keicoder/9321639 to your computer and use it in GitHub Desktop.
Save keicoder/9321639 to your computer and use it in GitHub Desktop.
objective-c : set the frame of the view
//set the frame of the view
/*
_theImageView.frame = CGRectMake(x, y, width, height);
Frame is in reference to its parent view,
Bounds are in reference to the view itself
*/
//ex
CGRect currentFrame = _theImageView.frame;
currentFrame.origin.x = 0;
currentFrame.origin.y = 0;
_theImageView.frame = currentFrame;
[_parentView addSubview:_theImageView];
//Alternatively, you can say:
CGRect currentFrame = _theImageView.frame;
_theImageView.frame = CGRectMake(0, 0, currentFrame.size.width, currentFrame.size.height);
[_parentView addSubview:_theImageView];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment