.h文件
import
@interface HUPrompt : UIView
.m文件
import "HUPrompt.h"
import "UIView+Layout.h"
@implementation HUPrompt
UIImageView *backView = [[UIImageView alloc] init];
backView.frame = self.frame;
backView.image = _backImage;
[self addSubview:backView];
self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, label.bottom+23, 74, 32)];
self.button.isPercentSize = YES;
self.button.backgroundColor = Btn_COLOR;
[self.button setTitle:@"知道了" forState:UIControlStateNormal];
[self.button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.button addTarget:self action:@selector(cancle1) forControlEvents:UIControlEventTouchUpInside];
self.button.titleLabel.font = TextSize;
self.button.layer.cornerRadius = 15;
self.button.layer.masksToBounds = YES;
[backView addSubview:self.button];
self.button.isHorizontalCenter = YES;
-(void)cancle1{
NSLog(@"sdfdsfds");
}
然后我在uiviewController调用 能显示 frame是传进来了的 但是不能点击 没触发事件 我想是不是uiview中不能用addTarget这个方法啊 求解答