gpt4 book ai didi

ios - 如何添加按钮边框 - ios

转载 作者:行者123 更新时间:2023-11-29 02:17:43 26 4
gpt4 key购买 nike

我正在开发一个应用程序。如何添加按钮边框。我试过谷歌搜索,但对我没有任何用处。谁能帮我。我的应用程序中的按钮是 IBAction 而不是 IBOutlet

viewController.h

@interface ViewController : UIViewController


@property (strong, nonatomic) IBOutlet UIButton *buttonOneMoved;
@property (strong, nonatomic) IBOutlet UIButton *buttonTwoMoved;
@property (strong, nonatomic) IBOutlet UIButton *buttonThreeMoved;
@property (strong, nonatomic) IBOutlet UIButton *buttonFourMoved;
@property (strong, nonatomic) IBOutlet UIButton *buttonFiveMoved;

- (IBAction)buttonOne:(id)sender;
- (IBAction)buttonTwo:(id)sender;
- (IBAction)buttonThree:(id)sender;
- (IBAction)buttonFour:(id)sender;
- (IBAction)buttonFive:(id)sender;


@end

viewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.


}

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

- (IBAction)buttonOne:(id)sender {
}

- (IBAction)buttonTwo:(id)sender {

}

- (IBAction)buttonThree:(id)sender {

}

- (IBAction)buttonFour:(id)sender {

}

- (IBAction)buttonFive:(id)sender {

}
@end

最佳答案

如你所知,一个按钮可以一个“IBOutlet”并指向一个“IBAction”。

但是如果你想突出显示被按下的按钮,你可以这样做:

- (IBAction)buttonOne:(id)sender {
UIButton *myButton = (UIButton *)sender;

[[myButton layer] setBorderWidth:2.0f];
[[myButton layer] setBorderColor:[UIColor greenColor].CGColor];
[myButton setNeedsLayout];

}

answer for which I found here , 或 you could do this also .

关于ios - 如何添加按钮边框 - ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28559796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com