提高iOS开发效率的小技巧与思路

2020-01-15 16:13:42王冬梅

先用一张图展示学习iOS开发应该掌握的知识体系:

ios开发小技巧,ios开发思路

1.全图片作为背景的时候,可能遇到的问题。,滑回的时候,图片停留了一会才滑回去。

原因: 这种界面一般使用一般用imageView的第三种填充方式。

ios开发小技巧,ios开发思路

这种填充方式可以让图片不被压缩变形的前提下,尽可能去填充整个控件,但是设置这个枚举的填充方式的时候,记得按照下图这样设置,将超出控件范围的给切割掉

ios开发小技巧,ios开发思路

设置约束的时候,记得选择currentview的那个对象

ios开发小技巧,ios开发思路

2.设备适配的问题

还是上面这张图片,按照设计在6p上面来设置自动约束,约好后,在5s上面的时候,下面的爱心在自动约束的设置下面和专业设置太近,这时候挺影响美观的,这时候第一反应当然是根据设备来进行调整,但是我觉得这里完全可以使用下面这种方式来进行判断设置


 CGFloat top = 0;
  CGFloat left = 0;
  CGFloat bottom = 0;
  CGFloat right = 0;

  if ([UIScreen ff_screenSize].width == 375) {

    top = 80;
    left = 70;
    bottom = 31;
    self.titleLabel.font = [UIFont systemFontOfSize:18];
    self.englishLabel.font = [UIFont systemFontOfSize:20];
    self.introduceLabel.font = [UIFont systemFontOfSize:14];
    right = 33;

  }else if ([UIScreen ff_screenSize].width == 414){
    bottom = 31;
    top = 88;
    left = 84;
    right = 33;

  }else if ([UIScreen ff_screenSize].width == 320){

    self.titleLabel.font = [UIFont systemFontOfSize:16];
    self.englishLabel.font = [UIFont systemFontOfSize:18];
    self.introduceLabel.font = [UIFont systemFontOfSize:13];
    self.introduceTop.constant = 8;
    top = 70;
    left = 44;
    bottom = 24;
    right = 28;

  }

  self.collectionButtonLeft.constant = right;

  self.chineseLabelTop.constant = top;
  self.introlduceLeft.constant = left;
  self.collectionButtonbottom.constant = bottom;

  [self.view setNeedsLayout];

记得修改约束后调用一下[self.view setNeedsLayout]; 这也是很关键的一点,不调用没有效果。

3.数字动画效果

ios开发小技巧,ios开发思路