Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Fix the issue where instance scaling was broken if global one was ena…
Browse files Browse the repository at this point in the history
…bled.
  • Loading branch information
alexmx committed May 12, 2017
1 parent 82cf7ea commit d50dab5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AMXFontAutoScale.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "AMXFontAutoScale"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "Scale the font for UILabel and UITextView proportionally across all the screen sizes."

s.description = <<-DESC
Expand Down
8 changes: 4 additions & 4 deletions AMXFontAutoScale/UILabel+AMXFontScale.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ - (BOOL)wasInstanceAutoScaleSet

+ (void)load
{
[self amx_swizzleInstanceSelector:@selector(willMoveToSuperview:)
withSelector:@selector(swizzle_willMoveToSuperview:)];
[self amx_swizzleInstanceSelector:@selector(willMoveToWindow:)
withSelector:@selector(swizzle_willMoveToWindow:)];
}

- (void)swizzle_willMoveToSuperview:(UIView *)newSuperview
- (void)swizzle_willMoveToWindow:(UIWindow *)newWindow
{
AMXScreenSize referenceScreenSize = AMXScreenSizeCurrent;
if (self.amx_autoScaleEndabled) {
Expand All @@ -97,7 +97,7 @@ - (void)swizzle_willMoveToSuperview:(UIView *)newSuperview
self.font = [self.font amx_scaleForReferenceScreenSize:referenceScreenSize];
}

[self swizzle_willMoveToSuperview:newSuperview];
[self swizzle_willMoveToWindow:newWindow];
}

@end
6 changes: 3 additions & 3 deletions AMXFontAutoScaleDemo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class MainViewController: UIViewController {

@IBOutlet var helloLabels: [UILabel]!
@IBOutlet var sizeLabels: [UILabel]!

override func viewDidLoad() {
super.viewDidLoad()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

if helloLabels.count == sizeLabels.count {
for (index, helloLabel) in helloLabels.enumerated() {
Expand Down

0 comments on commit d50dab5

Please sign in to comment.