2

I am new to iPhone programming. I have to use the drawRect method to cut the view in an iPhone app. I implemented the drawRect method but it is not be called properly. Can anyone suggest how to resolve this problem?

Chris
  • 44,602
  • 16
  • 137
  • 156
Srinivas
  • 400
  • 1
  • 11
  • What do you mean by "cutting the view"? Also, please show what you've tried so far. – omz Jan 23 '12 at 08:54
  • Refer this link..i will definitely help you][1] [1]: http://stackoverflow.com/questions/7657465/uinavigationbars-drawrect-is-not-called-in-ios-5-0 – Misri Jan 23 '12 at 09:34

1 Answers1

0

Please double check have you subclassed uiview or uiviewcontroller,because this is a common mistake.

Abhinandan Sahgal
  • 1,076
  • 1
  • 13
  • 27
  • 1
    Thank you.I have taken UIViewController,but at that time it was not accessed.After that i have taken subclass of UIView,In that class i used drawRect method... – Srinivas Jan 23 '12 at 08:56
  • It is not working. I have written code in the subclass of UIView - (void)drawRect:(CGRect)rect { UIRectFill( rect ); CGRect gapArea = CGRectMake(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); CGRect rectTofill = CGRectIntersection(gapArea, rect ); [[UIColor clearColor] setFill]; UIRectFill( rectTofill ); } – Srinivas Jan 23 '12 at 09:12
  • and In touchesBegin method is in mainview controller... -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject];; // viewScreen.hidden=YES; CGPoint currentPosition = [touch locationInView: [touch view]]; CGRect rectValue=CGRectMake(currentPosition.x,currentPosition.y, 50,50); NewView *newInstance=[[NewView alloc]init]; [newInstance drawRect:rectValue]; [newInstance release]; } So please suggest me how to call that drawRect method. – Srinivas Jan 23 '12 at 09:12