I recently decided i wanted to get rid of xibs all together and just create my view programatically. i am a little confused as to how to do this.
so i know you can use [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:1.00] to make a color (for that example, white) and instead of using the normal 0-255 scale they use the percentages for some reason which is fine.
to simplify this, i made a method in MainView.m/h (below) that accepted the 0-255 RGB values and returns a UIColor with those values:
I call it in my loadview method in my view controller:
For some reason, it always comes up with a bright green color as the background and doesnt load of the text fields or buttons or anything i later add to the view. What is the proper way to do this... i am confused.
so i know you can use [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:1.00] to make a color (for that example, white) and instead of using the normal 0-255 scale they use the percentages for some reason which is fine.
to simplify this, i made a method in MainView.m/h (below) that accepted the 0-255 RGB values and returns a UIColor with those values:
Code:
- (UIColor *)RGBColorR:(double)red G:(double)green B:(double)blue {
return [UIColor colorWithRed:(red/255.00) green:(green/255.00) blue:(blue/255.00) alpha:1.00];
}
I call it in my loadview method in my view controller:
Code:
- (void)loadView {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [self RGBColorR:236 G:229 B:206];
{...}
}
Note: I do not have a MainView.xib at all, I deleted it.
For some reason, it always comes up with a bright green color as the background and doesnt load of the text fields or buttons or anything i later add to the view. What is the proper way to do this... i am confused.