Reputation: 203
I have the following code in .h file:
#import <UIKit/UIKit.h>
@interface SCLoginViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *btnLogin;
@end
and the following code in .m file:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Do any additional setup after loading the view from its nib.
// Add gradient to the buttons
btnLogin.layer.cornerRadius = 10;
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = btnLogin.layer.bounds;
gradientLayer.colors = [NSArray arrayWithObjects:
(id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,
(id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,
nil];
gradientLayer.cornerRadius = btnLogin.layer.cornerRadius;
[btnLogin.layer addSublayer:gradientLayer];
// Add shadow
btnLogin.layer.shadowColor = [UIColor darkGrayColor].CGColor;
btnLogin.layer.shadowOpacity = 1.0;
btnLogin.layer.shadowOffset = CGSizeMake(2.0, 2.0);
}
This is how the button sits on the screen:
Something is horribly wrong though. I know I am missing something simple, but can't figure it out. I created regular outlet called btnLogin but any change I try to make to it is not working. The button is rounded rect button. I tried Custom button and that didn't help.
Thank you!
Upvotes: 1
Views: 93
Reputation: 14834
From the image, I see that you did not make a connection from your btnLogin on the nib file to the file's owner - .h file. So this line below has no connection to the button that you are trying to make changes.
@property (weak, nonatomic) IBOutlet UIButton *btnLogin;
Once you make that proper connection, it should show up the btnLogin name where Referencing Outlets is on the image you provided.
Upvotes: 1