标签:ide htm ted 移动 button gic base str close
sizeToFit()
会调用sizeThatFits(_:)
方法,将现在的frame
作为参数。然后根据函数返回的结果更新view。
sizeToFit will simply call through to sizeThatFits: passing the view's current size as the argument. It will then update the view's frame based on the value it gets back. So all the important logic goes in sizeThatFits:, and this is the method you should override for your own custom controls.
myButton?.titleLabel?.shadowOffset = CGSizeMake(2.0, 2.0)
myButton?.setTitleShadowColor(UIColor.redColor(), forState: .Normal)
// myButton?.showsTouchWhenHighlighted = true
myButton?.reversesTitleShadowWhenHighlighted = true
加上选中态亮瞎眼的效果
myButton?.showsTouchWhenHighlighted = true
有三个UIEdgeInsets
sizeThatFits(_:)
计算时用到。sizeThatFits(_:)
计算时不会用到。sizeThatFits(_:)
计算时不会用到。You can specify a different value for each of the four insets (top, left, bottom, right). A positive value shrinks, or insets, that edge—moving it closer to the center of the button. A negative value expands, or outsets, that edge.
举例说明
sizeThatFits(_:)
的计算,所以最终表现为整个button被拉宽。sizeThatFits(_:)
中不参与,因此button没有被拉宽,只是titleLabel的左边向右(中心)移动了15pt,右边保持不变。导致字符串没有被显示全。button.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
标签:ide htm ted 移动 button gic base str close
原文地址:http://www.cnblogs.com/huahuahu/p/UIButton-de-tan-mi.html