As shown above, the figure I used to ask the volume of the red circle area is how the layout? Is Collection View it? Thank you
Reply:
Reply:
This should be achievable
UICollectionViewOf course, his own position is calculated to achieve the same can be done. The bottom of the frame directly into a picture, just need to be concerned about the position of the upper icon and title. You can define a model class to encapsulate what
Reply:
I basically can be achieved, but how to make perfectly centered inside the grid? Like a text box to set the center the same.
http://www.cocoachina.com/bbs/read.php?tid=168709
Reply:
I said the following scenario is not based on UICollectionView to achieve.
Each entity
box, you can customize a control, the control name is defined as CustomCell, the cell receives a physical model, contains the icon and title
@ interface CellModel: NSObject
@ Property (nonatomic, strong) NSString * iconName;
@ Property (nonatomic, strong) NSString * title;
@ End
@ Class CellModel;
@ Interface CustomCell: UIView
@ Property (nonatomic, strong) CellModel * model;
- (Id) initWithModel: (CellModel *) cm;
@ End
# Import "CellModel.h"
@ Implement CustomCell
- (Id) initWithModel: (CellModel *) cm {
if (self = [super init]) {
self.model = cm;
}
return self;
}
- (Void) layoutSubview {
if (nil! = self.model) {
/ / / / / Draw icon
CGRect bounds = self.bounds;
UIImage * iconImg = [UIImage imageNamed: self.model.iconName];
UIImageView * iconView = [[UIImageView alloc] initWithImage: iconImg];
/ / / / / Compute position. Set iconview's frame
iconView.frame = CGRectMake ((bounds.width-iconImg.size.width) / 2, 5, iconImg.size.width, iconImage.size.height);
[Self addSubview: iconView];
/ / / / / / Draw title
UILabel * lblTitle = [[UILabel alloc] init];
[LblTitle setTitle: self.model.title];
[LblTitle setColor; [UIColor black]];
[LblTitle setFont: [UIFont fontWithsize: 12]];
[LblTitle setNumberOfLines: 0];
[LblTitle setLineBreakModel: NSLineBreakWordWarpping];
CGSize titleSize = [lblTitle.text sizeWithFont: lblTitle.font];
lblTitle.frame = CGRectMake ((bounds.width-titleSize.width) / 2, CGRectGetMaxY (iconView.frame) +5, titleSize.width, titleSize.height);
[Self addSubview: lblTitle];
}
}
@ End
The above is just part of the pseudo-code, pure handwriting, is not guaranteed to be completely correct. The general idea should be.
Reply:
Hand write so thank you. Today getting a hang of a sudden, I found that this problem is actually quite easy.
First, set a good first cell width. cell directly without voids, so that all cell are the average lateral distribution. Then put inside the picture centered just fine.
As shown below:
Brother so powerful free to answer my question now.
Consult a similar calendar to achieve a similar effect http://www.cocoachina.com/bbs/ read.php? tid = 168789
No comments:
Post a Comment