高度必须整数倍
YXRoundPixelValue()
+ (CGFloat)scale
{
static CGFloatscale = -1;
if(scale <0) {
scale = [UIScreenmainScreen].scale;
}
returnscale;
}
CGFloat YXRoundPixelValueForScale(CGFloatf,CGFloatscale) {
// Round to the nearest device pixel (.5 on retina)
returnroundf(f * scale) / scale;
}
CGFloat YXRoundPixelValue(CGFloatf) {
returnYXRoundPixelValueForScale(f, [YXScreenscale]);
}