How I can change the value of a constraint on only one device. For example, I want to display a button with 400px height for all iPhones except iPhone 4 where I would display it with 300px ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The best solution is to create new class inherit from NSLayoutConstraint class and add the properties below, like that you will have the possibility to change the constant, the multiplier and also to deactivate the constraint for each device and all this in the interface builder :
import UIKit
/**
* This class used to modify easly the constraint for each device iPhone 4, iPhone 5, iPhone 6 or iPhone 6 Plus
* You can modify the constant, the multiplier and also active / deactive the constraint for each device
* You should modify this properties only in the storyboard
*/
@IBDesignable
public class LayoutConstraint: NSLayoutConstraint {
// MARK: