[iphoneDev] 演示如何画出UIVIEW的一部分画面. 类似于遮罩的效果.

iphone Dev tutorial:演示如何画出UIVIEW的一部分画面. 类似于遮罩的效果. 拖拽一个UIVIEW到其他的VIEW上就会只画出 当前被遮挡住的部分类似于 FLASH中的MASK效果。

下面是核心的函数::

//  Created by cnsoft on 08-10-16.
//  Copyright cnsoft 2008. All rights reserved.
//  NDA License.

-(void) drawMaskView {
  if(selView ==0 || maskView ==0)
   return;
 
 CGRect newrect = [maskView frame];
 CGRect newrect2 = [selView frame];
 
 CGRect bound = CGRectMake(0,0,0,0);
 bound.origin.x = (newrect2.size.width – newrect.size.width)/2;
 bound.origin.y = (newrect2.size.height – newrect.size.height)/2;
 bound.size.width = newrect.size.width;
 bound.size.height = newrect.size.height;
 
 [selView setAlpha:0.8];
 [selView setFrame:newrect2];
 [selView setBounds:bound];
 [selView setNeedsDisplay];
 [viewParent bringSubviewToFront:selView];
}

还有个问题没有解决, 就是如果是有圆角的UIVIEW 如何处理呢???  

 update     clip draw view  worked fine!

Leave a comment

1 Comments.

  1. 你好
    Can you please email me the whole xcode project files ?
    Thanks!

Leave a Reply


[ Ctrl + Enter ]

click to change验证码

无觅相关文章插件