2014-08-28 5 views
0

У меня есть пользовательский UIView, который мне нужно добавить в контроллер родительского контроля, но пользовательский UIView не отображается.Objective-c, добавляя пользовательский UIView к контроллеру родительского представления

// 
    // ViewController.m 
    // InstantForum 
    // 
    // Created by trikam patel on 27/08/2014. 
    // Copyright (c) 2014 trikam patel. All rights reserved. 
    // 

    #import "ViewController.h" 
    #import <FacebookSDK/FacebookSDK.h> 

    @interface ViewController() 

    @end 

    @implementation ViewController 
    @synthesize loginSignupControlView; 

    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 

     CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; 

     self.loginSignupControlView = [[LoginSignupControlView alloc] initWithFrame:CGRectMake(0, 0, 320, 68)]; 
     [self.view addSubview:self.loginSignupControlView]; 

     // Do any additional setup after loading the view, typically from a nib. 
    } 


    - (void)didReceiveMemoryWarning 
    { 
     [super didReceiveMemoryWarning]; 
     // Dispose of any resources that can be recreated. 
    } 

    @end 


     // 
    // LoginSignupControlView.m 
    // InstantForum 
    // 
    // Created by trikam patel on 28/08/2014. 
    // Copyright (c) 2014 trikam patel. All rights reserved. 
    // 

    #import "LoginSignupControlView.h" 

    @implementation LoginSignupControlView 

    - (id)initWithFrame:(CGRect)frame 
    { 
     self = [super initWithFrame:frame]; 
     if (self) { 
     [self createView]; 
     // Initialization code 
     } 
     return self; 
    } 

    - (id)initWithCoder:(NSCoder *)aDecoder { 
     if ((self = [super initWithCoder:aDecoder])) { 
     [self createView]; 
     } 
     return self; 
    } 

    -(void)createView{ 

     CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; 
     self.backgroundColor = [UIColor colorWithRed:56 green:56 blue:57 alpha:1.0f]; 

    } 


    /* 
    // Only override drawRect: if you perform custom drawing. 
    // An empty implementation adversely affects performance during animation. 
    - (void)drawRect:(CGRect)rect 
    { 
     // Drawing code 
    } 
    */ 

    @end 

ответ

1
self.backgroundColor = [UIColor colorWithRed:56 green:56 blue:57 alpha:1.0f]; 

равно:

self.backgroundColor = [UIColor whiteColor]; 

попробовать это!

self.backgroundColor = [UIColor colorWithRed:56.f/255 green:56.f/255 blue:57.f/255 alpha:1.0f]; 
+0

Thank you @Nicolas Bonnet – redoc01

Смежные вопросы