开发中使用的语言技巧

  1. result 的值变化范围是 0 - valueRange / 2, valueRange / 2 - 0, 0 - valueRange / 2, valueRange / 2 - 0;
	static int rote = 0;
    int valueRange = 20;
    int maxValue = valueRange / 2;
    int a = rote % valueRange;
    int b = rote / maxValue;
    int c = b % 2;
    int result = (valueRange * c + a * (pow(-1, c)));
    rote++;
  1. result 的值变化范围是 0 - valueRange, 0 - valueRange, 0 - valueRange, 0 - valueRange;
	static int rote = 0;
    int valueRange = 20;
    int result = (rote % valueRange );
    rote++;
  1. scorllView的子view的布局
    NSArray  * viewsArray;
    UIScrollView *scrollView;
    __block UIView *lastView = scrollView;
    [viewsArray enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj mas_makeConstraints:^(MASConstraintMaker *make) {
            MASViewAttribute * mas_ori = (idx == 0) ? lastView.mas_left : lastView.mas_right;
            make.left.equalTo(mas_ori).offset(5);
            make.top.bottom.equalTo(scrollView);
            if (idx == viewsArray.count - 1) make.right.equalTo(scrollView);
        }];
        lastView = obj;
    }];

你可能感兴趣的:(项目中使用的技巧)