iOS SDK:通过代码将按钮移动到屏幕中心 [英] iOS SDK: Moving the button into the center of screen by code

查看:12
本文介绍了iOS SDK:通过代码将按钮移动到屏幕中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过代码将按钮移动到屏幕中央.我在某处看到它只是几行代码,但找不到它们.

I want to move a button to the center of the screen by code. I saw somewhere it is just few lines of code, but could not find them.

推荐答案

应该这样做:

yourButton.frame = CGRectMake(self.view.frame.size.width/2 - yourButton.frame.size.width/2, self.view.frame.size.height/2 - yourButton.frame.size.height/2, yourButton.frame.size.width, yourButton.frame.size.height);

这篇关于iOS SDK:通过代码将按钮移动到屏幕中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆