Coder Social home page Coder Social logo

fittablefontlabel's People

Contributors

madhavajay avatar minimistro32 avatar rolandkakonyi avatar sweeper777 avatar tbaranes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fittablefontlabel's Issues

fontSizeThatFits() does not work when text is ""!

I just added a label to the storyboard, set up the constraints so that its bounds fills the whole screen. Then, in viewDidLayoutSubviews, I did this:

    // note that the label's text is not empty string here
    print(label.fontSizeThatFits(text: "00:00", maxFontSize: 500))
    print(label.fontSizeThatFits(text: "00:00:00", maxFontSize: 500))

And the values printed seems good. The first is larger than the second.

But if I do this:

    label.text = ""
    print(label.fontSizeThatFits(text: "00:00", maxFontSize: 500))
    print(label.fontSizeThatFits(text: "00:00:00", maxFontSize: 500))

It prints 17 and 17!

After looking into the source code, I think there is something wrong with the currentAttributedStringAttributes() method. But I'm quite inexperienced in dealing with NSAttributedStrings so I can't figure out what is wrong.

Can you fix this?

Why does the text not fit in the label in this case?

I have a label that says "5" like this:

2017-09-09 10 09 53

2017-09-10 7 35 38

At runtime, it shows up like this:

2017-09-09 10 09 20

As you can see, the font size is too big. I cannot figure out why this is. I've set the "lines" property to 0 so it should fit both the width and height. I have also selected "Word Wrap" like you've said in README.

Xcode freezes when I set the class of the label to FittableFontLabel

After installing the pod, I dragged a UILabel into a view controller's view. In the identity inspector, I typed "FittableFontLabel" in the "Class" textfield. Then Xcode freezes. I can do nothing but to force quit. I tried multiple times and the same thing happens: as soon as I typed "FittableFontLabel", Xcode just freezes!

I'm using Xcode 7.3.1 and CocoaPods 1.0.0.

Any ideas why?

SPM not working

After adding FittableFontLabel as a package with Swift Package Manager this error comes up:

"the manifest is missing a Swift tools version specification; consider prepending to the manifest '// swift-tools-version:5.5.0' to specify the current Swift toolchain version as the lowest Swift version supported by the project; if such a specification already exists, consider moving it to the top of the manifest, or prepending it with '//' to help Swift Package Manager find it"

Get adjusted font size

After job is done, give the ability to retrieve the adjusted font size. Then this value can be saved and the computation done only once.

multiline size state

private func multiLineSizeState(rect: CGRect, size: CGSize) -> FontSizeState { // if rect within 10 of size if rect.height < size.height + 10 && rect.height > size.height - 10 && rect.width > size.width + 10 && rect.width < size.width - 10 { return .fit } else if rect.height > size.height || rect.width > size.width { return .tooBig } else { return .tooSmall } }

Hi, rect.width > size.width + 10 && rect.width < size.width - 10, Is there any mistake here?

Add a fontSizeThatFits() method!

The label that I'm using is a little special. I can't just set the text of it and call fontSizeToFit to get the font size that fits. Can you add a method in the UILabel extension that returns a font size of the argument text that fits the label's size.

The signature is like this:

public func fontSizeThatFits(text: String, size: CGSize = self.bounds.size) -> CGFloat

The basic idea is that I give you some text, and the method will figure out how big the text should be to just fit the size of the label.

I think you must have this as a private method, right? Can you just make it public?

Memory usage is too high

Hello,

I am importing and using FittableFontLabel into my project. While it is certainly very useful, the memory usage in-app due to library is very high. My app frequently hangs(and eventually force closes) since I have imported this.

I see in What's next that something is being done regarding this?

Thanks!

Should add UILabel inset option

Great solution.
I've been struggling with fitable uilabel and NSAttributedString.
But i think you should provide inset option, because some kind of font will lose it apart if we leave inset = 0 and alignment = right.

Thanks

Error in FittableFontLabel.swift

Change This:

open override func drawText(in rect: CGRect) {
let insets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
super.drawText(in: rect.inset(by: insets))

With This: (swift 4.2)

open override func drawText(in rect: CGRect) {
let insets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
}

}

cannot compile in swift 4 project

I added the pod to my workspace but then I get compile errors in UILabelExtension:

Cannot assign value of type '[NSAttributedStringKey : Any]' to type '[String : Any]'
Cannot subscript a value of type '[String : Any]' with an index of type 'NSAttributedStringKey'
Cannot convert value of type '[String : Any]' to expected argument type '[NSAttributedStringKey : Any]?'

Binary search using 0.5 iterator and Swift compatibility

What do you think about using 0.5 delta for each iteration during the binary search? (See example https://github.com/ShingoFukuyama/UILabel-FontSizeToFit)

I'm facing a use case where the font is considered .Fit 0.5pt too soon, maybe because the next iteration is considered .TooSmall and thus my text is truncated.

Also I can't move to Swift 3.x right now, what do you think about creating a separator release cycle for 2.3 support?
Per semver, breaking changes should bump major version number (see changelog).

Thanks!

The text does not fit the label's frame when it is multiline.

To reproduce this problem, add a FittableFontLabel to a storyboard. Set its text to be for example "Hello\nWorld\nBye\nWorld". Set the numberOfLines property to either 0 or 4, the lineBreakMode to word wrap and the height to something small. When the height is too small, the text does not fit in the label anymore and may only show "Hello" or "Hello\nWorld".

The UILabel extension increases font size, but not enough on the iPad

I am using an LTMorphingLabel to display some text that I want to fill the screen with. So I call fontSizetoFit() on the LTMorphingLabel. And this is the result, viewed in the view hierarchy:

screen shot 2016-07-28 at 8 30 40 am

The selected view is the frame of the LTMorphingLabel. As you can see, the text could have been much larger!

This only seems to be a problem on iPads though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.