-1

我试图为我的应用程序实现裁剪功能,就像 Instagram 那样。

示例:http: //i.imgur.com/Dq12OAx.png

我需要以矩形的形式创建一个 UIView,中间有一个方形的“孔”。我不知道从哪里开始,所以感谢所有帮助。

4

1 回答 1

0

Its pretty easy. Just subclass UIView, and override drawrect.

- (void)drawRect:(CGRect)rect {
    //draw the non-transparent view here, or fill the whole view like
    [[UIColor blackColor] setFill];
    UIRectFill( rect);

    //define the position and size of the "hole"
    CGRect yourHole = CGRectMake(left, top, width, height);

    //fill that section with clear color
    [[UIColor clearColor] setFill];
    UIRectFill( yourHole );
}
于 2013-07-08T05:14:44.010 回答