jailani
jailani

Reputation: 2270

Change the color of the rect in UIVIew in ios?

I have an UIView X which is green color of size (0,0,100,100). I need to change the green color to clear color of that view in particular portion like rect(30,30, 40, 40). So only I can see the view that behind X.

Thanks in advance

Upvotes: 0

Views: 415

Answers (1)

Retro
Retro

Reputation: 4005

 Try this, I hope this would will help..


 - (void)drawRect:(CGRect)rect { 

    CGRect greenRect = CGRectMake(0, 0, rect.size.width, rect.size.height/2.0);
    // Fill the rectangle with grey
    [[UIColor greenColor] setFill];
    UIRectFill( topRect );

    CGRect clearRect = CGRectMake(0, rect.size.height/2.0, rect.size.width, rect.size.height/2.0);
    [[UIColor clearColor] setFill];
    UIRectFill( bottomRect );

}

Upvotes: 1

Related Questions