I currently have two UIViews: A red background and other blue blue scene is a subview of Red View What I would like to do , Be able to "cut" the rectangles on the blue scene so that the red scene can be visible. How can you go about doing this?
You must override the of the top view
method, for example, You can get the HoleyView
class from UIView
(by adding a new file to your project, choosing the Object-C subclass, and selecting "Subclass of" to UIView
) HoleyView
, drawRect
will look something like this:
- (zero) drawRect: (CGRect) Rect {// start filling area with blue color [[UIColor blueColor] setFill]; UIRectFill (rect); // Assume that the name of an arm is a hole type type CGRact // We can just fill the hole, but only to fill the area is more efficient, which we are being asked to attract. CGRTC Chore Direct Injection = CGRCT Intelligence (Hocharctact, Rect); [[UIColor clear collar]] Setfill; UIRectFill (Thickening Injection); }
If you are using the interface builder, make sure to change the class of hidden views to holiview
you see the interface builder and the inspector You can do this by selecting the "Identity" pane in (on the right side of an "I" icon).
You also have to set top view non-opaque with either the following code snippet or by un-checking the opaque
checkbox in the properties of the view in the interface builder (see you Set the ambiguity of the background color for the viewing section in the View section and 0% (the background color is set in the same section).
topView.opaque = NO; TopView.backgroundColor = [UIColor clear collar];
If you want to create circles, you have to use the core graphics
(aka quartz 2D). You may want to read the programming guide, which is available.
Rect {// Get current graphics context CGContextRef context = UIGraphicsGetCurrentContext (); CGContextSetFillColorWithColor (Reference, [UIColor blueColor] .CGColor); CGContextFillRect (reference, rect); If (CGRTIntectectsectector (holractext, reticulate)) {CGContactTitTiller with collar (context, [UCLLAR clear collar] .cg color); CGContextFillEllipseInRect (reference, paragraph); }}
Comments
Post a Comment