mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-04 12:14:29 +00:00
add assertion for ASRelativeDimensionTypePercent value to be between 0-1 (#2009)
This commit is contained in:
committed by
Adlai Holler
parent
6a21daa80f
commit
ff2c47c415
@@ -18,16 +18,21 @@ ASRelativeDimension const ASRelativeDimensionUnconstrained = {};
|
||||
ASRelativeDimension ASRelativeDimensionMake(ASRelativeDimensionType type, CGFloat value)
|
||||
{
|
||||
if (type == ASRelativeDimensionTypePoints) { ASDisplayNodeCAssertPositiveReal(@"Points", value); }
|
||||
if (type == ASRelativeDimensionTypePercent) {
|
||||
ASDisplayNodeCAssert( 0 <= value && value <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", value);
|
||||
}
|
||||
ASRelativeDimension dimension; dimension.type = type; dimension.value = value; return dimension;
|
||||
}
|
||||
|
||||
ASRelativeDimension ASRelativeDimensionMakeWithPoints(CGFloat points)
|
||||
{
|
||||
ASDisplayNodeCAssertPositiveReal(@"Points", points);
|
||||
return ASRelativeDimensionMake(ASRelativeDimensionTypePoints, points);
|
||||
}
|
||||
|
||||
ASRelativeDimension ASRelativeDimensionMakeWithPercent(CGFloat percent)
|
||||
{
|
||||
ASDisplayNodeCAssert( 0 <= percent && percent <= 1.0, @"ASRelativeDimension percent value (%f) must be between 0 and 1.", percent);
|
||||
return ASRelativeDimensionMake(ASRelativeDimensionTypePercent, percent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user