Skip to content

Commit

Permalink
Make the DownView reflow text on device rotation (#127)
Browse files Browse the repository at this point in the history
Setting the meta viewport tag to width=device-width reflows the text to match the frame width of the DownView.
  • Loading branch information
phoney authored and rob phillips committed Mar 23, 2019
1 parent 8db1802 commit 8d0dcae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Down-Example/Down-Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
9 changes: 8 additions & 1 deletion Down-Example/Down-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ class ViewController: UIViewController {
self.present(alertController, animated: true, completion: nil)
}

downView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(downView)

NSLayoutConstraint.activate([
downView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
downView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
downView.topAnchor.constraint(equalTo: topLayoutGuide.topAnchor),
downView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.bottomAnchor)
])

createStatusBarBackgrounds()
}

Expand All @@ -50,4 +58,3 @@ class ViewController: UIViewController {
}

}

2 changes: 1 addition & 1 deletion Resources/DownView.bundle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=640"/>
<meta name="viewport" content="width=device-width,user-scalable=false"/>
<link charset="utf-8" href="css/down.min.css" rel="stylesheet">
<script charset="utf-8" src="js/highlight.min.js" type="text/javascript"></script>
<script charset="utf-8" src="js/down.js" type="text/javascript"></script>
Expand Down

0 comments on commit 8d0dcae

Please sign in to comment.