मुझे UITableCells के बीच एक "स्पेस" होने की समान अवधारणा को करने की आवश्यकता थी। चूंकि आप शाब्दिक रूप से उन कक्षों के बीच स्थान नहीं जोड़ सकते हैं, जो आप इसे यूआईटेबल व्यू की सेल ऊंचाई में हेरफेर करके और फिर अपने सेल के contentView में एक UIView जोड़कर नकली कर सकते हैं। यहाँ एक प्रोटोटाइप का स्क्रीन शॉट है जो मैंने एक अन्य परीक्षण परियोजना में किया था जब मैं यह अनुकरण कर रहा था:

यहां कुछ कोड दिए गए हैं (नोट: प्रदर्शन उद्देश्यों के लिए बहुत कठिन कोडित मूल्य हैं)
सबसे पहले, मुझे heightForRowAtIndexPathUITableViewCell पर विभिन्न ऊंचाइयों की अनुमति देने के लिए सेट करने की आवश्यकता थी ।
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *text = [self.newsArray objectAtIndex:[indexPath row]];
if ([text isEqual:@"December 2012"])
{
return 25.0;
}
return 80.0;
}
आगे, मैं UITableViewCells के लुक और फील को मैनिपुलेट करना चाहता हूं इसलिए मैं इसे willDisplayCell:(NewsUITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPathविधि में करता हूं ।
- (void)tableView:(UITableView *)tableView willDisplayCell:(NewsUITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (cell.IsMonth)
{
UIImageView *av = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 20, 20)];
av.backgroundColor = [UIColor clearColor];
av.opaque = NO;
av.image = [UIImage imageNamed:@"month-bar-bkgd.png"];
UILabel *monthTextLabel = [[UILabel alloc] init];
CGFloat font = 11.0f;
monthTextLabel.font = [BVFont HelveticaNeue:&font];
cell.backgroundView = av;
cell.textLabel.font = [BVFont HelveticaNeue:&font];
cell.textLabel.textColor = [BVFont WebGrey];
}
if (indexPath.row != 0)
{
cell.contentView.backgroundColor = [UIColor clearColor];
UIView *whiteRoundedCornerView = [[UIView alloc] initWithFrame:CGRectMake(10,10,300,70)];
whiteRoundedCornerView.backgroundColor = [UIColor whiteColor];
whiteRoundedCornerView.layer.masksToBounds = NO;
whiteRoundedCornerView.layer.cornerRadius = 3.0;
whiteRoundedCornerView.layer.shadowOffset = CGSizeMake(-1, 1);
whiteRoundedCornerView.layer.shadowOpacity = 0.5;
[cell.contentView addSubview:whiteRoundedCornerView];
[cell.contentView sendSubviewToBack:whiteRoundedCornerView];
}
}
ध्यान दें कि मैंने अपनी whiteRoundedCornerView ऊंचाई 70.0 बनाई है और यही कारण है कि सिम्युलेटेड स्पेस का कारण बनता है क्योंकि सेल की ऊंचाई वास्तव में 80.0 है, लेकिन मेरा कंटेंट व्यू 70.0 है जो इसे उपस्थिति देता है।
इसे बेहतर तरीके से पूरा करने के अन्य तरीके भी हो सकते हैं लेकिन यह सिर्फ इतना है कि मैंने इसे कैसे किया। मुझे उम्मीद है कि यह किसी और की मदद कर सकता है।