UIView contentstretch将圆圈改为椭圆形,而不是药丸形状

时间:2011-06-03 18:29:35

标签: iphone objective-c

我有80个单位的80个单位的圆形图像,并试图使用UIImageView的contentstretch属性将其更改为药丸形状,但我只能得到一个椭圆形。有任何想法吗?这是我的代码:

imageView.frame = CGRectMake(0,0,80,80);
imageView.layer.contents = (id)([UIImage imageNamed:@"circle.png"]).CGImage;
imageView.contentStretch = CGRectMake(0.5, 0,0, 1);
[UIView animateWithDuration:0.5 delay: 0.0 options: UIViewAnimationOptionTransitionNone
animations:^{
    imageView.frame = CGRectMake(imageView.frame.origin.x,imageView.frame.origin.y, imageView.frame.size.width+50, imageView.frame.size.height);
        }
        completion:^(BOOL finished){

                             }];

1 个答案:

答案 0 :(得分:0)

你试过吗?

UIImage *circleImage = [UIImage imageNamed:@"circle.png"];
UIImage *stretchImage = [circleImage stretchableImageWithLeftCapWidth:40 topCapHeight:40];
imageView.image = stretchImage;