Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Allow images larger than than UITextField height
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoCardoso committed Oct 18, 2017
1 parent bb7c4b7 commit 0b23199
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Change Log

#### 1.x Releases
- `1.0.x` Releases - [1.0.1](#101)
- `1.0.x` Releases - [1.0.1](#101) | [1.0.2](#102)

---

## [1.0.2](https://github.com/LeonardoCardoso/RevealTextField/releases/tag/1.0.2)
Released on 2017-10-18.

#### Added
- Allow images larger than than UITextField height.
- Added by [Leonardo Cardoso](https://github.com/LeonardoCardoso).

## [1.0.1](https://github.com/LeonardoCardoso/RevealTextField/releases/tag/1.0.1)
Released on 2017-10-18.

Expand Down
2 changes: 1 addition & 1 deletion RevealTextField.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'RevealTextField'
s.version = '1.0.1'
s.version = '1.0.2'
s.license = { :type => "MIT", :file => "LICENSE" }
s.summary = 'Simple extension to add a reveal button to your boring UITextField'
s.homepage = 'https://github.com/LeonardoCardoso/RevealTextField'
Expand Down
3 changes: 2 additions & 1 deletion RevealTextFieldTests/RevealTextFieldTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class RevealTextFieldTests: XCTestCase {

func testRightView() {
textField?.revealable(secureImage: nil,
unsecureImage: nil)
unsecureImage: nil,
allowLargeImages: true)
XCTAssert(textField?.rightView != nil)

textField?.revealable(secureImage: nil,
Expand Down
5 changes: 3 additions & 2 deletions Sources/UITextField+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ extension UITextField {
public func revealable(secureImage: UIImage?,
unsecureImage: UIImage?,
tintColor: UIColor = .black,
dimension: CGFloat = 30) {
dimension: CGFloat = 30,
allowLargeImages: Bool = false) {

rtf_secureImage = secureImage?.withRenderingMode(.alwaysTemplate)
rtf_unsecureImage = unsecureImage?.withRenderingMode(.alwaysTemplate)

let safeDimension = dimension > frame.size.height ? frame.size.height : dimension
let safeDimension = dimension > frame.size.height && !allowLargeImages ? frame.size.height : dimension
let newFrame = CGRect(x: 0, y: 0, width: safeDimension, height: safeDimension)

let revealButton = UIButton(frame: newFrame)
Expand Down

0 comments on commit 0b23199

Please sign in to comment.