我在这里遇到了一个大问题。我已经以编程方式创建了几个按钮。出现在屏幕上但缺少一些偏好。
- (void) processImage:(UIImage *)image
{
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) {
image = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation: UIImageOrientationUp];
}
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) {
image = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation: UIImageOrientationDown];
}
if (capturedImageOneData == nil) {
capturedImageOneData = image;
[self resizeImage:image];
self.capturedImageOneSmall = [[UIButton alloc] init];
self.capturedImageOneSmall.frame = CGRectMake(3091, 50, 160, 120);
[self.capturedImageOneSmall setBackgroundImage:capturedImageResized forState:UIControlStateNormal];
[self.capturedImageOneSmall addTarget:self action:@selector(tappedOnImage:) forControlEvents:UIControlEventTouchUpInside];
self.capturedImageOneSmall.layer.cornerRadius = 8;
self.capturedImageOneSmall.tag = 401;
[self.capturedImageOneSmall addGestureRecognizer:longPressGesture];
[self.scrollView addSubview:self.capturedImageOneSmall];
如您所见,我对按钮进行了一些自定义。但是,例如,cornerRadius没有显示在图片中(锐边留下)。
有什么想法吗?
答案 0 :(得分:1)
尝试添加:
self.capturedImageOneSmall.layer.masksToBounds = YES;