如果设置button的frame时,width或者height为float类型并且值确实的小数的时候,image会显示不全,这时如果改成NSInteger类型就完整显示了.
原因不知道为什么...
CGFloat buttonW = 83.55;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"" forState:UIControlStateNormal];
[button setTitle:@"确定"forState:UIControlStateNormal];
button.frame = CGRectMake(100, 100, buttonW , buttonH);
[button setTitleColor:kJSColor(@"#000000", 1) forState:UIControlStateNormal];
button.titleLabel.font = kJSPingFang_R(14);
[self addSubview:button];
这时因为buttonW是float类型,图片就会被切掉一点.
NSInteger buttonW = 83;
改为这样图片就显示全了.