Device battery indicators on your Lock Screen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 line
1.3KB

  1. @implementation KAIStackView
  2. - (id)initWithFrame:(CGRect)arg1 {
  3. self = [super initWithFrame:arg1];
  4. self.translatesAutoresizingMaskIntoConstraints = NO;
  5. return self;
  6. }
  7. - (void)addArrangedSubview:(UIView *)view {
  8. [super addArrangedSubview:view];
  9. [[KAIBatteryPlatter sharedInstance] setContentSize:self.frame.size];
  10. if (textColor == 0 && [view respondsToSelector:@selector(updateInfo)]) {
  11. KAIBatteryCell *cell = (KAIBatteryCell *)view;
  12. if (@available(iOS 12.0, *)) {
  13. if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  14. [cell.label setTextColor:[UIColor whiteColor]];
  15. [cell.percentLabel setTextColor:[UIColor whiteColor]];
  16. } else if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
  17. [cell.label setTextColor:[UIColor blackColor]];
  18. [cell.percentLabel setTextColor:[UIColor blackColor]];
  19. }
  20. }
  21. }
  22. [[KAIBatteryPlatter sharedInstance] performSelector:@selector(resetOffset) withObject:[KAIBatteryPlatter sharedInstance] afterDelay:0.2];
  23. }
  24. - (void)removeArrangedSubview:(UIView *)subview {
  25. [super removeArrangedSubview:subview];
  26. [[KAIBatteryPlatter sharedInstance] performSelector:@selector(resetOffset) withObject:[KAIBatteryPlatter sharedInstance] afterDelay:0.2];
  27. }
  28. @end