如何将函数锚定到我以这种方式创建的 Button
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[button addTarget:self
action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
button.frame = CGRectMake(80.0, 160.0, 160.0, 40.0);
[button setTitle:string forState:UIControlStateNormal];
[self.view addSubview:button];
当我将功能链接到按钮时,我想做与 IB 类似的操作。是否可以?