Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我以编程方式创建了一个 UIButton,我想添加约束,以便它从底部保持相同的长度,因此它在 iPhone 4 和 5 上看起来都正确。
我知道如何在 Interface Builder 中执行此操作,但不知道如何以编程方式执行此操作。
将以下行放入.pch文件中
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
并编写iPhone 5如下代码
iPhone 5
if( IS_IPHONE_5 ) // Set Fram/ code for iPhone 5 else // Set Fram/ code for iPhone 4