UIViewController
의 backgroundColor
을 변경하려고합니다. 코드를 viewDidLoad
방법으로 작성했습니다. 내 다른 객체는 아무런 문제없이 화면에 표시되지만 backgroundColor
property
은 작동하지 않습니다. 화면은 gray
입니다. 또한 [UIColor redColor]
을 시도하거나 viewDidAppear
메서드에서이 행만 쓰려고했지만 아무 것도 변경되지 않았습니다.ViewController의 배경색을 viewDidLoad에서 변경할 수 없습니다.
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithRed:0.15
green:0.15
blue:0.3
alpha:1.0];
//Add start button
[self.view addSubview:[self createButton:@"ButtonSample.png"
setTitleColor:[UIColor whiteColor]
buttonPositionX:(CGRectGetMidX(self.view.frame)-30)
buttonPositionY:(CGRectGetMidY(self.view.frame)+30.0)
buttonWidth:80.0
buttonHeight:20.0]];
//Add game title label
[self.view addSubview:[self createLabel:@"Vecihi"
labelFontName:@"Chalkduster"
labelFontSize:20
labelPositionX:CGRectGetMidX(self.view.frame)-25
labelPositionY:CGRectGetMidY(self.view.frame)
labelWidth:80
labelHeight:20
fontColor:[UIColor whiteColor]]];
//Add game logo imageView
[self.view addSubview:[self createImage:@"Spaceship"
imagePositionX:CGRectGetMidX(self.view.frame)-30
imagePositionY:CGRectGetMidY(self.view.frame)-80
imageWidth:40
imageHeight:60]];
}
다른 곳의 배경색을 설정하는 것이 좋습니다. 뷰 컨트롤러 파일에서'backgroundColor' 문자열을 검색해보십시오. – Avt
배경색을 – user3235456
으로 설정 한 곳이 없다면이보기 컨트롤러에 대한 self.view 이외의 다른보기가 없다고 확신합니까? –