需要获取图片的尺寸,高*宽。
然后将值传递到下面的代码:
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(25, 5, imgView.size.width, imgView.size.width)];
但是总是不成功,不知道应该怎么实现?谢谢
需要获取图片的尺寸,高*宽。
然后将值传递到下面的代码:
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(25, 5, imgView.size.width, imgView.size.width)];
但是总是不成功,不知道应该怎么实现?谢谢
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(25, 5, imgView.size.width, imgView.size.width)];
你这样创建,这时的UIImageView还没有width及height.UIImageView 尺寸依据它添加的UIImage
UIImage *img=[UIImage imageNamed:@""];
UIImageView *imgView=[[UIImageView alloc] initWithImage:img];
imgView.frame=CGRectMake(25, 5, imgView.size.width, imgView.size.width);