Light's Blog

The best or nothing.

iOS知识小集-170731

| Comments

UIImage Tint Color

1
2
3
[cell.icon sd_setImageWithURL:[NSURL URLWithString:myURL] placeholderImage:[UIImage imageNamed:imageName] options:SDWebImageRefreshCached completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
    cell.icon.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}];

调整屏幕亮度

1
[[UIScreen mainScreen] setBrightness:0.5];

保持屏幕常亮

1
[UIApplication sharedApplication].idleTimerDisabled = YES;

iOS知识小集-170710

| Comments

Lottie

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with bodymovin and renders the vector animations natively on mobile and through React Native!
Common Animations

1
2
3
4
5
LOTAnimationView *animation = [LOTAnimationView animationNamed:@"Lottie"];
[self.view addSubview:animation];
[animation playWithCompletion:^(BOOL animationFinished) {
  // Do Something
}];

iOS知识小集-170703

| Comments

CAKeyFrameAnimation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
- (CAKeyframeAnimation *)circleShake {
  if (!_circleShake) {
    CGFloat baseX = self.circleMask.position.x;
    _circleShake = [CAKeyframeAnimation animationWithKeyPath:@"position.x"];
    _circleShake.keyTimes = @[
      @0,
      @(0.1 / 0.8),
      @(0.2 / 0.8),
      @(0.3 / 0.8),
      @(0.5 / 0.8),
      @(0.76 / 0.8)
    ];
    _circleShake.values = @[
      @(baseX),
      @(baseX - 11),
      @(baseX + 11),
      @(baseX - 11),
      @(baseX + 11),
      @(baseX)
    ];
    _circleShake.duration = 0.8;
    _circleShake.removedOnCompletion = YES;
    _circleShake.fillMode = kCAFillModeForwards;
  }
  return _circleShake;
}

iOS知识小集-170619

| Comments

Enable file sharing

Application Supports iTunes file sharing = YES

Image Slicing

使用Xcode Image Slicing图片需为标准的PNG图片。

TabBar

高度49

ComponentKit Tutorial

| Comments

What’s Component ?

Components are immutable objects that specify how to configure views.
A component is a fixed description that can be used to paint a view but that is not a view itself.