Search code examples
iosassistive

Moving button like assistive touch


Hi I want to move a uibutton where even I want in my app like we have Assistive touch in iphone so as a same I want that kind of button in my app..Is it possible to do that If so please help out with code are some links for that


Solution

  • This question is asked so many times.... here is answer

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
            UITouch *touch = [[event allTouches] anyObject];
            CGPoint touchLocation = [touch locationInView:self.view];
            button.frame.x = touchlocation.x;
            button.frame.y = touchlocation.y;
        }