ios - Animating rotated UIView causes it to disappear -


i have uiview 10 10, rotated 45 degrees create diamond shape.

here code rotates view:

triangle = [[uiview alloc] initwithframe:cgrectmake(35, kuserviewheight - 5, 10, 10)]; triangle.backgroundcolor = [uicolor coolblue]; //triangle.center = cgpointmake(5.0, 5.0); triangle.transform = cgaffinetransformmakerotation(m_pi_2 / 2); 

i have purposely commented out center value because messes setting location of view. aware issue.

the view shows perfectly, when animate, view moves supposed on way, disappears. when rid of triangle.transform property, view animates , not disappear, square instead of diamond.

here animation code:

[uiview animatewithduration:kanimationinterval animations:^{          triangle.frame = cgrectmake(115, kuserviewheight - 5, 10, 10);  }]; 

because plan on moving diamond shape around, setting center becomes problematic. how can both rotate view , animate across screen without disappearing? there kind of special way calculate center point need be? thanks!

yes u did u rotating 90 degree, u said disappearing, may helps u 1 thing while u animating order important


 uiview* triangle = [[uiview alloc] initwithframe:cgrectmake(35, 25, 10, 10)];  triangle.backgroundcolor = [uicolor colorwithred:1 green:.4 blue:1 alpha:1]; // seeting diff color not matter  [uiview animatewithduration:0.2 animations:^{   triangle.frame = cgrectmake(115, 20, 10, 10);//kuserviewheight = 25 - 5 (i assuming)          //it must after setting frame, put rotation 45 degree   triangle.transform = cgaffinetransformmakerotation(m_pi/4);//it m_pi/4 not m_pi /2  }];    //  triangle.transform = cgaffinetransformmakerotation(m_pi/4); //you can put hear or within animation block   


hopes helps u :)


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -