私のコード:</p>
- (void)showWithStatus:(NSString *)status barColor:(UIColor*)barColor textColor:(UIColor*)textColor click:(SEL)click{
if(!self.superview)
[self.overlayWindow addSubview:self];
[self.overlayWindow setHidden:NO];
[self.topBar setHidden:NO];
self.topBar.backgroundColor = barColor;
NSString *labelText = status;
CGRect labelRect = CGRectZero;
CGFloat stringWidth = 0;
CGFloat stringHeight = 0;
if(labelText) {
CGSize stringSize = [labelText sizeWithFont:self.stringLabel.font constrainedToSize:CGSizeMake(self.topBar.frame.size.width, self.topBar.frame.size.height)];
stringWidth = stringSize.width;
stringHeight = stringSize.height;
labelRect = CGRectMake((self.topBar.frame.size.width / 2) - (stringWidth / 2), 0, stringWidth, stringHeight);
}
self.stringLabel.frame = labelRect;
self.stringLabel.alpha = 0.0;
self.stringLabel.hidden = NO;
self.stringLabel.text = labelText;
self.stringLabel.textColor = textColor;
clickBn=[[UIButton alloc]initWithFrame:self.stringLabel.frame];
clickBn.backgroundColor=[UIColor blueColor];
[clickBn addTarget:self action:click forControlEvents:UIControlEventTouchUpInside];
if(!clickBn.superview)
[self.topBar addSubview:clickBn];
[UIView animateWithDuration:0.4 animations:^{
self.stringLabel.alpha = 1.0;
}];
// [self setNeedsDisplay];
}
そして、このメソッドを呼び出します:
- (IBAction)successButtonPressed:(id)sender {
[KGStatusBar showSuccessWithStatus:@"Successfully synced" click:@selector(clickBn)];
}
- (void)clickBn {
NSLog(@"sss");
[KGStatusBar dismiss];
}
NSLog(@"sss") は表示されません。customViewのUIButtonにメソッドを渡したいのですが、UIButtonをクリックしても反応しません。