2
我希望在imageview的左上角和右下角創建刪除按鈕。但它看起來不像我所需要的。如何在UIImageView的左上角和右下角創建UIButton
我希望這兩個按鈕應放置在紅色邊框
的角球製造我用下面
UIImageView * tappedView = (UIImageView *)[recognizer view];
[tappedView.layer setBorderColor: [[UIColor redColor] CGColor]];
[tappedView.layer setBorderWidth: 2.0];
tappedView.layer.cornerRadius = 10;
tappedView.layer.masksToBounds = NO;
UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
deleteBtn.frame = CGRectMake(0, 0, 20, 20);
[deleteBtn setImage:[UIImage imageNamed:@"close.png"]forState:UIControlStateNormal];
deleteBtn.layer.shadowColor = [[UIColor blackColor] CGColor];
deleteBtn.layer.shadowOffset = CGSizeMake(0,4);
deleteBtn.layer.shadowOpacity = 0.3;
[tappedView addSubview:deleteBtn];
[deleteBtn addTarget:self action:@selector(deleteProperties:) forControlEvents:UIControlEventTouchUpInside];
UIButton *zoomBtn = [UIButton buttonWithType:UIButtonTypeCustom];
zoomBtn.frame = CGRectMake(tappedView.frame.size.width, tappedView.frame.size.height, 20, 20);
[zoomBtn setImage:[UIImage imageNamed:@"close.png"]forState:UIControlStateNormal];
zoomBtn.layer.shadowColor = [[UIColor blackColor] CGColor];
zoomBtn.layer.shadowOffset = CGSizeMake(0,4);
zoomBtn.layer.shadowOpacity = 0.3;
[tappedView addSubview:zoomBtn];
[zoomBtn addTarget:self action:@selector(ZoomIn:) forControlEvents:UIControlEventTouchUpInside];
代碼按鈕請指導我。
我想這樣
是的。如果我將(-5,-5,20,20)放置在確切的位置,但在按鈕上出現紅色邊框,我已經嘗試過這一個。 – thavasidurai
@Brendt我應該刪除我的帖子?兩個聲音都一樣.... – Spynet
@Brendt我編輯了我的問題請看它。 – thavasidurai