Getting Screen width and height in Xcode objective C
Im creating a new subview in XCode using CGRectmake. This I can do fine.
But I would like to make the size of the new view 10 pixels less than the
screen width. I normally work with Java and would use screen.width-10 to
do this. But with ObjC in Xcode I'm not sure how to and couldn't find the
info i needed. This what I have so far it creates a box on a button tap
but i would like to change the width from 100 to screen width - 10.
//Info Button
-(IBAction) buttonTapped:(id)sender {
// create a new UIView
UIView *newView = [[UIView alloc]
initWithFrame:CGRectMake(10,10,100,100)];
// do something, e.g. set the background color to red
newView.backgroundColor = [UIColor redColor];
// add the new view as a subview to an existing one (e.g. self.view)
[self.view addSubview:newView];
// release the newView as -addSubview: will retain it
[newView release];
}
Thanks in advance.
No comments:
Post a Comment