Marquee and static UILabel text - iphone

In my application i have two options to display text in UILabel .First is to use marquee like effect , so that long text can scroll along its width. I am using size of 350 for marquee. Other option is called static. In this however long is the text it should not marquee and show whole text in UILabel. UIlabel should adjust its font and size so as to fit in the frame of uiview i.e width = 480 and height = 320 in landscape mode. I have completed with the marquee animation but i am not able to figure out how to display static tex in uilabel so that it will changes its size and font according to the length of text.

AS alternative you can create same thing with UIView and Timer. Please refer below URL
https://github.com/jeffhodnett/JHTickerView
https://github.com/MugunthKumar/MKTickerViewDemo
https://github.com/caydenliew/CLTickerView
HTML marquee not working in iOS 5.1

Related

Autosize button

In the past i've created several buttons that changes the size for iPads or iPhones, like this and works well:
Now i want to create new buttons but the size do not change.
I set Width to 400 and Height to 100 on iPad, the aspect ratio is 200:50 but the size do not change, when i change to iPhone (its still 400x100)
iPad size:
iPhone X size:
The button is huge and do not shrink as the working buttons in pic1.
What i'm doing wrong?
You can simply remove the height, width and aspect ratio constraints. Some UI elements like UIButton and UILabel auto-size themselves based on their contents.
Also, an advice:
Never ever set width and height for buttons and labels. Once you get into changing strings from outside the storyboard, such as when localizing your app, you'll get clipped strings without noticing it.
If you want to increase the hit-area for buttons, work with content / title insets instead.

Large width of UILabel Cause memory issue

I want some marquee label type control in my application. I have created it but the problem is as below:
1.I have setup the scrollview first and then in that scrollview i have added UILabel with large text around 7000 character.and i am shifting content offset of the UIScrollView to make a text scrolling.
Now when allocating label, i make the width of the label according to the stringsize width like below:
UIFont *font = autoScrollLabel.font;
CGSize stringSize = [str1 sizeWithFont:font];
float width = stringSize.width;
and i give this width (its around 250000) to the UILabel width Like below:
autoScrollLabel.frame = CGRectMake(15,25,width,98);
=====
Now the problem is if i am allocating this width to UILabel with then it occupy around 300MB size of the application and at some instant it crashed the application due to memory issue.
Can anyone had ever faced this issue then please help on how to solve this memory issue or anyone who have any idea please put you suggestion.
I have also other functionality like play, pause, scroll text with animation, and move the text offset according to the UISlider and start it from there.
Thanks
A UILabel will render all the text at once event if it is off the screen. This is what is causing your memory issue.
As an alternative, could you use a UITextView in your code to achieve the same functionality?
UITextView inherits from UIScrollView so you can set the textview's frame to bounds of the superview but adjust the contentSize property to stringSize
Edit: Sorry, the above wouldn't work as you cannot control the way the UITextView renders its text.
How about trying this: https://github.com/cbpowell/MarqueeLabel

Text cut off in UitextView? How to scroll text page by page properly

I am trying to scroll text in UITextView manually up and down with the help of uibuttons.
This is how I am doing.
[storyTextView setContentOffset:CGPointMake(storyTextView.contentOffset.x, scrollPoint-scrollFraction) animated:NO];
Where
scrollPoint=storyTextView.frame.size.height;
When I scroll up or down, text goes cut off.
See this image:
A UITextView clips it's subviews by default, so either you resize your UITextView to fill as much as you want, or you uncheck "Clip Subviews" in your xib, or with code
[storyTextView setClipsToBounds:NO];
Try this
[storyTextView setContentInset:UIEdgeInsetsMake(5, 0, 5, 0)];
Ok the problem is like this.Your font size is large and mathematically you are setting up the content offset but only depends on the textview frame not the contents height.
Solution is to find out a proper algorithm to get the contents properly visible and then apply the content offset and then move with that specific height such that the text appears correctly.

How to make UITextView which finish text with dots according to contentSize?

I have a UITextview with dynamic data and i have a size with height let's say 200, how i can crop text in UITextField text to much the height and add "..." to it ?
is this text view supposed to be enabled for input?
if yes, then you shouldn't be cropping the text
if no, then you could use a UILabel and change the numberOfLines to display, and then set the lineBreakMode property to UILineBreakModeTailTruncation

Core Text - How to grow UIView?

I am using Core Text (for text bleed/wrap effect). Since the body of the UIView has to grow with the text and images put onto the view, I want my UIView to adjust its height accordingly.
I tried sizeToFit (on my UIView) to adjust its height according to its contents. However, the UIView doesn't increase its height, although it can decrease it alright.
This is how my hierarchy of the UIView looks like:
[UITextView]
[UIImageView] (can be 0 or many)
How could I make my UIView adjust its height according to the contents it has?
I am putting the text in a UITextView and then displaying it in the UIView (using CoreText), so I basically set the height of my UIView as:
(height of textview) + (height of images)
Although it isn't an elegant solution but atleast it works alright.
PS: a better solution might be to add a right proportion of height and width (since the text wraps around the image).