Reputation: 6381
I have added the button in storyboard like the following picture:
I also have added the code in the header file as shown in the following code:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIPickerViewDataSource,UIPickerViewDelegate>
@property (strong, nonatomic) IBOutlet UIButton *Up;
@property (strong, nonatomic) IBOutlet UIButton *Back;
@property (strong, nonatomic) IBOutlet UIButton *Left;
@property (strong, nonatomic) IBOutlet UIButton *Ok;
@property (strong, nonatomic) IBOutlet UIButton *Right;
@property (strong, nonatomic) IBOutlet UIPickerView *DeviceSelect;
@end
I want to add the style for the UIButton
in the .m file as shown in the following code:
self.Up = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:_Up];
But it seems its not working. The UIButton
didn't change anything.
Did I miss something?
I am new to iOS , Please teach me... Thanks in advance.
Upvotes: 1
Views: 1589
Reputation: 89519
You've already added your button in the storyboard file and because you added buttons that way, you should not do these two lines of code:
self.Up = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:_Up];
You can set the button style via the attributes inspector in Xcode's Interface Builder (which you see when editing the storyboard).
It looks like this:
Upvotes: 1