iphone - Change size of MaskedLayer over UIView -


i have 2 uiimageviews occupy whole screen meaning frames : (0,0,320,480). imageview2 on top of imageview1.

they both have masks applied them using cashapelayer. have made function

-(void)addmask:(cgrect)rect toview:(uiimageview*)imageview  

which follows

//function -(void)addmask:(cgrect)rect toview:(uiimageview*)imageview {  cashapelayer * shapelayer = [[cashapelayer alloc] init];  cgpathref path = cgpathcreatewithrect(rect, null); shapelayer.path = path; cgpathrelease(path);  imageview.layer.mask=shapelayer; imageview.layer.maskstobounds=yes;  } 

i applying masks on uiimageviews in viewdidappear using following cgrects:

//in view did appear [self addmask:cgrectmake(0,0,160,480) toview:self.imageview]; [self addmask:cgrectmake(160,0,160,480) toview:self.imageview2]; 

so result screen half split showing half imageview1 on left side , half imageview2 on right side.

i have button hooked ibaction(buttonpressed:).

what want achieve when button pressed mask of imageview1 increased while of mask of uiimageview2 decreased : imageview1 on left occupy 75% of screen while imageview2 on right occupty 25% of screen. trying right in code below not getting desired results:

//in ibaction cgrect tmprect ; tmprect = imageview1.layer.frame; nslog(@"rect1  : %@",nsstringfromcgrect(tmprect)); tmprect.size.width+=20.0; [self addmask:tmprect toview:self.imageview];  tmprect= imageview2.layer.frame; nslog(@"rect2 : %@",nsstringfromcgrect(tmprect)); tmprect.origin.x+=20.0; tmprect.size.width-=20.0; [self addmask:tmprect toview:self.imageview2]; 

the output

2013-08-26 13:15:41.753 imagemasking[16191:c07] rect1  : {{0, 0}, {320, 460}} 2013-08-26 13:15:41.754 imagemasking[16191:c07] rect2 : {{0, 0}, {320, 460}} 

heres picture view of m trying achieve.

enter image description here

also later on move masks using pangesture. idea apply masks thousand times while fingers being dragged using function ?
there other alternative trying achieve might entirely wrong in approach.

thanks

the problem on button press going layer.frame full frame of image view, not current frame masking to. should store position of split line, cgfloat, in property , want modify mask, first update property , use calculate new mask paths.

you shouldn't worry performance until have reason to. i.e usage / testing tells you need make change. should profile find out causing problem , work on that.

that said, shouldn't need create new shape layer each time, update path.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -