UIView contentstretch changes circle to oval, not to pill shape
I have a circle image 80 units by 80 units and was trying to use the contentstretch property of the UIImageView to change it into 开发者_JAVA技巧a pill shape, but I can only get an oval. Any ideas? Here is my code:
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){
}];
Did you try?
UIImage *circleImage = [UIImage imageNamed:@"circle.png"];
UIImage *stretchImage = [circleImage stretchableImageWithLeftCapWidth:40 topCapHeight:40];
imageView.image = stretchImage;
精彩评论