Changing background in UIView using code from XIB in ios

I created a windows-based project, then added a new view manager with xib to test the user interface, and then, entering in xib, I made some settings for the view, added some buttons and also changed the background color.

But now I want to change the background color as code, not via xib,

so I tried this in my

-(void)viewDidLoad
{
    UIColor *myColor = [UIColor colorWithRed:(128.0 / 255.0) green:(90.0 / 255.0) blue:(200.0 / 255.0) alpha: 1];
    self.view.backgroundcolor = mycolor;

}

but nothing has changed, so please help me with friends

Thanks and Regards Ranjit

+5
source share
4 answers

, , . . - , -

#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

[self.view setBackgroundColor: RGB(135, 182, 44)]; //will give a UIColor objct
+14

, , . backgroundColor viewDidLoad. , , , , viewDidAppear:.

viewDidAppear:, .

, .

[[NSOperationQueue mainQueue] addOperationWithBlock:
 ^{
     [UIColor colorWithRed:(128.0 / 255.0) green:(90.0 / 255.0) blue:(200.0 / 255.0) alpha: 1];
 }];
+1

- , . self.view NSLog, ? , ? ?

0

: XIB , , , .

, , , , , , view.layer.cornerRadius, .

, XIB .

0

All Articles