Description:
We are adding UILabels as subviews of UIView on vertical manner and height of the subviews as calculated by current display width. If height of the subview as decimal value then unwanted spaces will be displayed between subviews.
Steps to Reproduce:
- Run the attached project
- See the reported issue
Expected Behavior:
Remove the unwanted space between the subviews
Actual Behavior:
There is some unwanted space between the subviews
Code Snippet :
- (void)viewDidLoad {
[super viewDidLoad];
[self view].backgroundColor = UIColor.redColor;
//// If the height value has decimal value then the issue will raise.
double heightValue = 36.60f;
double offsetValue = 100;
for (int i = 0; i < 10; i++)
{
UILabel* label = [[UILabel alloc] init];
label.backgroundColor = UIColor.whiteColor;
label.text = @"Demo";
label.frame = CGRectMake (offsetValue, offsetValue + i * heightValue, offsetValue, heightValue);
[self.view addSubview:label];
}
}
Sample: https://drive.google.com/open?id=1Lf1JXbEWupwMoh2A5ohcolSLgJDrGjCp
ScreenShots: https://drive.google.com/open?id=1VUY6-Sv34_vScqs1Qoh_lCRSMt137ER4