Scrolling NSString in NSView - objective-c

I'm using the method posted here to scroll an NSString across the screen. However, as shown in the image below, the string doesn't seem to be drawing correctly. Anyone have any ideas? Thanks.
EDIT: I forgot to mention that I modified the scrolling text class to use an attributed string rather than a regular string.
EDIT 2: I think the problem is that the string is repeating before it can finish the first time. How can I add some spacing before the string repeats itself?

Try clearing the area before drawing by adding
NSRectFillUsingOperation(dirtyRect, NSCompositeClear);
at the beginning of drawRect:.

I figured it out. I had to change this line in drawRect::
otherPoint.x += dirtyRect.size.width;
to
otherPoint.x += (stringWidth + 20.0);
EDIT: You can change 20.0 depending on how much of a gap you want before the string repeats.

Related

Amcharts4 legend label not truncated when value is right aligned

I am creating a pie chart with the legend at the bottom. I have added the config to truncate the legend label by passing
chart.legend.labels.template.maxWidth = 120;
chart.legend.labels.template.truncate = true;
Works fine until i try to right align the value by passing
chart.legend.valueLabels.template.align = "right";
After adding this, the labels are not truncated and occupy the full width.
Any help on how to achieve both truncating and also having the values aligned to the right would be much appreciated. Also I could not find any adapter method to overwrite the label. If so, I can strip the label after certain characters and return.
Here is a codepen demo of the above mentioned issue.
It was an issue acknowledged by the amcharts team and it was fixed later.

Uitextview expand to right

I have a uitextview in a tableviewcell, and I would like to know, how can I get the textview to expand to the right (ie let me keep typing without making line breaks and doing the scrolling thing). thanks
For every container, just like this one, you can set the maximumNumberOfLines to 1, which will limit the number of line breaks.
you can do it simple by set max number of lines
textview.textContainer.maximumNumberOfLines=1;

How can i achieve Multiline UILabel with NSLineBreakByTruncatingMiddle and sizeToFit in autolayout?

I have a two line UILabel. I want its line break mode NSLineBreakByTruncatingMiddle. The problem i am getting is if text is small enough to fit in one line, its showing it in middle of label instead of at top. I am using iOS6 and autolayout so sizeToFit is not working for me.
How can i achieve this? I want if text is small to fit one line it should be vertically top aligned. I have tried this, but its truncating and showing the text in one line only rather than two line.
You need to calculate the required size and update the frame of your label:
CGSize s = [myLabelString sizeWithFont:...
constrainedToSize:CGSizeMake(..., MAXFLOAT)
lineBreakMode:NSLineBreakByTruncatingMiddle];
With whatever font your label is using and its width.

UILabel object overlaps UITextfield in custom table cell after changing text property

I have specified a custom cell containing a label and a text field in a nib file.
When I change the text property of the label and adding three of those cells in a section of a table view it looks like this:
When I don't touch the text property and simply adding the cell out of the nib file "as is" it looks like this
Well there still remains the question why the textfields right edge moved, but that is not the main problem. Can somebody tell me how I have to configure the label to avoid that nasty behavior when changing the labels text?
Change the frame of your UILabels. Now it looks like they are about 280-300px wide. Change it to something less, 120 for example.
yourTextField.frame = CGRectMake(0, 0, 120, 30);
or some other numbers. Play with it.
Hope it helps
P.S. some code would be nice
Aaaah the great mysteries of autoresizingMask. Do it like this:
Resize your labels width and can always change label background to clear
yourLabel.backgroundColor=[UIColor clearColor];

Labelsize appears bigger in VB.Net

I'm trying to stack a few lists on top of each other. But the label.size.height appears to be bigger then the label itself.
When i set the borderstyle to fixedsingle, i see the border around the text. But the height is bigger, so there comes a space between one label and the next.
I have tried to set margin and padding to 0 without result.
Exemple: label.size.height return 23, when the height actually is something around 15.
Does someone knows how i get the right size?
Edit:
When i explicitly set the height of the lable, the problem is solved. Is this some problem with autosize?
I had encounter this kind of problem earlier. The label height oscillated between 17 and 23. But, my labels were placed inside a TableLayoutPanel and so how I fixed it :), by making changes in Designer.cs
HTH