OGeek|极客世界-中国程序员成长平台

标题: ios - 如何获取 UIButtom 的框架或边界已在 Storyboard 上设置 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:28
标题: ios - 如何获取 UIButtom 的框架或边界已在 Storyboard 上设置

我无法获取在 Storyboard 上设置的 UIButtom 的框架或边界。如下图所示,控制台只返回 0。那么如何获取框架或编码的界限?

enter image description here



Best Answer-推荐答案


CGRect f2 = yourButton.frame;
NSLog(@"x origin: %f\n", f2.origin.x);
NSLog(@"y origin: %f\n", f2.origin.y);
NSLog(@"height: %f\n", f2.size.height);
NSLog(@"width: %f\n", f2.size.width);

别忘了设置 IBOutlet。

关于ios - 如何获取 UIButtom 的框架或边界已在 Storyboard 上设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33210292/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4