Curve Text In UILabel Programmatically Around UIButton - text

I have created a circular UIButton by setting the cornerRadius property to half of the width and height values of the UIButton.
btn.layer.cornerRadius = 75.f;
That works fine but I would like to also create a label for the UIButton where the label text curves around the edge of the UIButton.
If this is even possible could somebody post a snippet of code as to how this curved text around the button edge could be accomplished?

You might have a look at this question: Curve text on existing circle
It's not actually a UIButton, but you will certainly get an idea of how to draw text on a curve.
There's especially talk of the sample project CoreTextArcCocoa from Apple. It's for OS X instead for iOS, but you might want to check this out.

Related

How to clip vega-lite text inside a rect?

In a webpage created with node/webpack, vega-lite, and vegaEmbed, I have a layer with rect marks with short annotations inside them using text marks. I'd like to clip the text to its surrounding rect but haven't figured out a way to do this and hope someone can point me in the right direction.
I realize text has a limit property in pixel units. If I could determine the pixel units of my rect marks (I don't know how to do this), using limit seems like a reasonable approach.
Also, if I knew the pixel extents of my rectangle, I can then write code to align the text within the rect which would be desirable. Currently I just use the same x as the rect, with a dx offset.
I've read about background for text which is a similar problem, but not the same.

Making a drawing game using phaser

I am developing a game using Phaser where a user is rendered a triangular canvas. User can crop this canvas to any possible shape by drawing any crop pattern on the canvas. Besides this, i need to get this cropped canvas in suitable data format to be used as an image to render and also trace changes made on this canvas for undoing puspose.
Any help to get this through will be appreciated.
Thanks in advance.
Initial canvas
Canvas after crop
Cropped canvas used to create new canvas
So it's like folding a piece of paper and then cutting it so it looks like a snowflake? Interesting idea.
I think you could either use BitmapData to draw the initial cut out, then copy that bitmap 6 (or 12?) times and rotate and flip x-axis to construct the rest. Though maybe there will be seems, so like small lines, between the parts idk.
Another appproach would be to keep track of the initial cutlines like vectors. Then use math/trigonometry to calculate the result. No idea how to do this though, sorry.

Monotouch: BarItem badge tint color?

When I set the badge value, it's red background with white font.
Is it possible to change the background color of the badge to eg. blue?
I had to do this recently and there isn't a built-in way.
But really, it's not that hard to write your own:
Have a graphic designer make you 3 images: left side, right side, and a 1 pixel wide image you can stretch for larger numbers
Make a new control and inherit from UIView
Use a UILabel and three UIImageViews for each picture
The only slightly difficult part is going to be measuring the length of the text for centering.
Rolling your own let's you make it exactly how you need. I exposed a int? Value property that made extremely easy to use from within my apps as well as a ValueChanged event.

Moving elements on a layout controlled programmatically

My goal is to create something like the arrow from car that indicates the speed of the car. My problem is that I do not know what is the best practice for moving the green arrow. I have an image arrow.png and I guess I need to manipulate with the place that the picture is shown and with the rotation of the image.
Can someone point to me some guidelines ?
My basic idea is to have a relative layout for the background and to have one image view that will change the position, but the part changing position is little unclear to me. And I do not think that is good idea to play with layout params and margins...
I would probably extend ImageView then override your onDraw method and use canvas.rotate() to rotate the arrow depending on your app state.

Transparency problem with gradient - Label in a Panel on a UserControl, ultimately displayed on parent Form

I know this has been asked many times, but not quite the way I'm trying to solve it.
I have Labels in a Panel on a UserControl, and the UserControl goes onto a form.
The Label.BackColor = Transparent.
The panel is from DevExpress, and I've set a gradient background.
Problem: The Labels aren't transparent; they each show as a white solid rectangle around the text. (I presume the white comes from the Panel, as the first of the two gradient colors is White.)
Everything I google about this problem says I need to roll my own Label control and fire off peculiar GDI+ commands, and Invalidate the control, and hook the Paint event and sing a stirring sea shanty and hold one foot above my head and...
Really? Doesn't the Label allow ".BackColor=Transparent" ? Why doesn't that work?
And what's the best way through this?
Somehow it turns out I never tried making the Label backgrounds transparent.
I am not a proud.

Resources