ios - Swift- how to position an item when working with a UIScrollView -


So I currently have a UIScrollView that allows the user to stand at the bottom of the page. I also have a UIBarButton that creates a button in the center of the clicked page, however, because of the UIScrollView I can not tell the button a simple CGRectMake coordination because the "center" of the screen is dependent on how far the user is scrolling down I am not using story boards.

Many thanks

Need to stay inside scrollwheel Adds to ScrollView's supervision

  the Button.frame = CGRect (x: scrollView.center.x, y: scrollView.center.y, width: buttonWidht, height: buttonHeight) scrollViewSuperView .addSubview (the Button)  

If it needs to be inside the scroll view, then you need to calculate the current Y Center. You can add it to the current scrolloff by adding the height of the scrollView And can divide it by 2

  currYenter = (scrollView.contentoffset.y + scrollView.frame.size.height) / 2 TheButton.frame = CGRect (X : ScrollView.center.x, y: currYenter, width: buttonWidht, height: button high) scrollView.addSubview (the button)  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -