IOS . -转载-10行代码搞定九宫格
//每个Item宽高 CGFloat W = 80; CGFloat H = 100; //每行列数 NSInteger rank = 4; //每列间距 CGFloat rankMargin = (self.view.frame.size.width - rank * W) / (rank - 1); //每行间距 CGFloat rowMargin = 20; //Item索引 ->根据需求改变索引 NSUInteger index = 9; for (int i = 0 ; i< index; i++) { //Item X轴 CGFloat X = (i % rank) * (W + rankMargin); //Item Y轴 NSUInteger Y = (i / rank) * (H +rowMargin); //Item top CGFloat top = 50; UIView *speedView = [[UIView alloc] init]; speedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"taozi"]]; speedView.frame = CGRectMake(X, Y+top, W, H); [self.view addSubview:speedView]; }
人这一辈子没法做太多的事情,
所以每一件都要做得精彩绝伦。
你的时间有限,
所以不要为别人而活。
不要被教条所限,
不要活在别人的观念里。
不要让别人的意见左右自己内心的声音。
最重要的是,
勇敢的去追随自己的心灵和直觉,
只有自己的心灵和直觉才知道你自己的真实想法,
其他一切都是次要。
工作是生活的一部分,所以工作不能全部占用于生活。