Vra

I have a UIView subview within a superview whose frame may extend outside the frame of the superview:

e.g. superview.frame = CGRectMake(0,0,100,100); subview.frame = CGRectMake(50,50,60,60);

i.e The subview will 'protrude' from the superview by 10 pixels in the bottom right corner.

How can I make it so only the portion of the subview that is within the superview frame is visible, and the protruding part invisible?

Context: The subview is actually a UILabel, which cannot be resized. If it protrudes, I want to display half the text only.

Was dit nuttig?

Oplossing

Set the superview's clipsToBounds property to YES.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top