【发布时间】:2013-07-10 05:41:01
【问题描述】:
我在 XIB 文件中使用了 UIView。在这个视图中有一个 UIImageView 和一个相同大小的按钮。我想让那个视图变圆,为此我使用cornerRadius。视图的大小是 92 * 92,这就是为什么我要使用 46 的角半径来使其变圆的原因。下面是我的代码,我正在评论我在代码本身中遇到的问题。
- (void)viewDidLoad
{
[super viewDidLoad];
_roundView.layer.cornerRadius = 46;
flag=0;
selectImage.layer.cornerRadius = 46;
NSLog(@"%f",_roundView.frame.size.height);
NSLog(@"%f",_roundView.frame.size.width);
imageFrame = selectImage.frame;
// when first view appear its perfectly round
// this is how i pick image from gallery
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info {
self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([lastChosenMediaType isEqual:(NSString *)kUTTypeImage]) {
UIImage *chosenImage = [info objectForKey:UIImagePickerControllerEditedImage];
UIImage *shrunkenImage = shrinkImage(chosenImage, imageFrame.size);
self.imagee = shrunkenImage;
NSLog(@"%f",_roundView.frame.size.height); nslog = 92
NSLog(@"%f",_roundView.frame.size.width); nslog = 92
NSLog(@"%f",_roundView.layer.cornerRadius); nslog = 46
NSLog(@"%f",selectImage.frame.size.height); nslog = 92
NSLog(@"%f",selectImage.frame.size.width); nslog = 92
NSLog(@"%f",selectImage.layer.cornerRadius); nslog = 46
selectImage.image = imagee;
selectImage.layer.cornerRadius = 46;
// now the issue is Image gets selected but it become rectangular 92 * 92
}
[picker dismissModalViewControllerAnimated:YES];
}
【问题讨论】:
标签: iphone ios cornerradius