UIButton
1.设置按钮按下会发光
button.showsTouchWhenHighlighted=NO;
2. 设置按钮内部图片间距和标题间距
UIEdgeInsets insets; // 设置按钮内部图片间距
insets.top = insets.bottom = insets.right = insets.left = 10;
bt.contentEdgeInsets = insets;
bt.titleEdgeInsets = insets; // 标题间距
UILbable
1. UILineBreakModeWordWrap = 0, 以单词为单位换行,以单位为单位截断。
UILineBreakModeCharacterWrap, 以字符为单位换行,以字符为单位截断。
UILineBreakModeClip, 以单词为单位换行。以字符为单位截断。
UILineBreakModeHeadTruncation, 以单词为单位换行。如果是单行,则开始部分有省略号。如果是多行,则中间有省略号,省略号后面有4个字符。
UILineBreakModeTailTruncation, 以单词为单位换行。无论是单行还是多行,都是末尾有省略号。
UILineBreakModeMiddleTruncation, 以单词为单位换行。无论是单行还是多行,都是中间有省略号,省略号后面只有2个字符。
UIImageView
1.这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有以下几个常量可供设定:
UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFit
UIViewContentModeScaleAspectFill
UIViewContentModeRedraw
UIViewContentModeCenter
UIViewContentModeTop
UIViewContentModeBottom
UIViewContentModeLeft
UIViewContentModeRight
UIViewContentModeTopLeft
UIViewContentModeTopRight
UIViewContentModeBottomLeft
UIViewContentModeBottomRight
注意以上几个常量,凡是没有带Scale的,当图片尺寸超过 ImageView尺寸时,只有部分显示在ImageView中。UIViewContentModeScaleToFill属性会导致图片变形。UIViewContentModeScaleAspectFit会保证图片比例不变,而且全部显示在ImageView中,这意味着ImageView会有部分空白。UIViewContentModeScaleAspectFill也会证图片比例不变,但是是填充整个ImageView的,可能只有部分图片显示出来。
2.更改位置
2.1 直接修改其frame属性
2.2 修改其center属性:
imageView.center = CGPointMake(CGFloat x, CGFloat y);
center属性指的就是这个ImageView的中间点。
2.3 使用transform属性
imageView.transform = CGAffineTransformMakeTranslation(CGFloat dx, CGFloat dy);
其中dx与dy表示想要往x或者y方向移动多少,而不是移动到多少。
3.旋转图像
imageView.transform = CGAffineTransformMakeRotation(CGFloat angle);
要注意它是按照顺时针方向旋转的,而且旋转中心是原始ImageView的中心,也就是center属性表示的位置。
这个方法的参数angle的单位是弧度,而不是我们最常用的度数,所以可以写一个宏定义:
#define degreesToRadians(x) (M_PI*(x)/180.0)
4.缩放图像
imageView.transform = CGAffineTransformMakeScale(CGFloat scale_w, CGFloat scale_h);
其中,CGFloat scale_w与CGFloat scale_h分别表示将原来的宽度和高度缩放到多少倍
5.播放一组图片
imageView.animationImages = imagesArray;//imagesArray是一些列图片的数组
imageView.animationDuration = [imagesArray count]; // 设定所有的图片在多少秒内播放完毕
imageView.animationRepeatCount = 0; // 不重复播放多少遍,0表示无数遍
[imageView startAnimating]; // 开始播放
UITextField
1.myTextField.adjustsFontSizeToFitWidth = YES;//设置为YES时文本会自动缩小以适应文本窗口大小。默认是保持原来大小,而让长文本滚动