custom button with multiple images - iphone

i have 3 images that i would like to use them to generate my custom button. my images are left.png 5x20, right.png 5x20 and mid.png 1x20. my mid.png must be repeated as long as my text lenght. how can i generate it in iphone application on the fly?
thanks.

Look at the leftCapWidth property on UIImage. You need to combine the images into a single PNG file, and then tell it the pixel width of the left part using that property. Then when that UIImage is drawn, it'll resize correctly.

Related

How to overlay text on image using swift?

First of all, I am using Auto Layout for this Swift application. In one view, i have an image that scales to full screen. And over this image there is an overlay text.
The problem is; When opening in iPhone6, the image scales and fits nicely but the text misplaces (normally) on the image, since the constraints are still the same.
I was thinking of merging the text and the image into one image layer so they scale and fit together. Is this possible ?
Or, anyone knows any other solution rather than trying to understand device and changing text placement contstraints accordingly ?
if you are using auto layout for display text in Lable. than must you have to play with constrain from interface builder. share you screenshot

Delphi - How to make a PNG image the main form?

I have an application which the main form of it its called Fmain. How can i make the Fmain to be the PNG image which i have as Image1 assigned in my source?
FMain.brush.bitmap:=Image1.picture.bitmap;
that's for if the Image1 is a *.bmp one, but i need the transperancy of my PNG file.
I don't think you will be able to make a custom shaped TForm with a transparent png.
Have a a look at this answer Irregularly shaped forms and more specifically to this http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.TransparentColorValue .
Are you wanting to make a form that has an odd shape? As in, you want to have the transparent parts of the PNG not be clickable as a form? If so then you are going about it the wrong way. If you were to put an image on the form and set the transparent properties on the image, then all you will do is see the form behind the image.
If you want to have a form that is the shape of the visible area of the PNG then you need to create an oddly shaped form. This is done by using regions and SetWindowRgn.
Luckily there is a handy tool out there for this: Gabes OddForm Assistant. I have used this to great effect a number of times.
In order to use it you will need to save your PNG as a bitmap and then load it into the utility. Once it is done it will give you the code required to make the form. You can just have a look in the pas file it creates and see how it is done, tinkering if you feel the need. You can either use the form directly or graft the code to where you need it.
Hope this helps.

UIsegment control Text size problem iphone

I have made a segment control.
In that my title is too much long .. so it is not shown properly..
Can Anyone tell me how to fix this problem??
I think there is no documented way to change the font.
But you can change the width of each segment using
[yourSegmentedControl setWidth:somethingLargeEnough forSegmentAtIndex:segmentIndex];
(though it may not be sufficient in your case)
#rathodrc:
It is not possible to change the font size for the segmented control but there is a work around for this, if you have fixed segment titles.
For Example:
Say if title for each segment is fixed that segmentedControl with 3 segments have titles(say SegA,SegB and SegC)
Then you can create images for each segment of segmentedcontrol with Segment title on it.
There you can keep larger or smaller fonts as per your requirement while creating images with text written on the image itself and then simply set images for each of the segments in the XIB.
Keep in mind, the image size should be exactly same as width and height of segment.
NOTE:
If you give the segment titles dynamically and it keeps on changes dynamically in your app then it is not possible.
Hope this helps you. :-)
The solution is to use the fact that a segmented control can also be built from an array of UIImages.
You can convert from text to UIImage this way:
How do I use the NSString draw functionality to create a UIImage from text
It should be fairly easy to change the fontsize.

Modifying, coloring and dragging pre-existing images iPhone application

I am developing an iphone application which would let me modify the image by dragging other images over its top along with functionality that would let me choose a specific color from the image and replace it with some other color shades i choose. If anyone has some clue like how to actually implement it or some code, that would be great help for me to proceed in right direction
Thanks in advance :)
If you just want to overlay images, you can simply drag UIImageViews around and position them within the view hierarchy such that the appropriate images are overlaid one on top of the other.
For generating a new image out of those composited images, you may want to use something like CGContextDrawImage() within a UIView subclass's -drawRect: method or in a custom CGContext. You can also refer to these similar questions:
How can we combine images and get image object from this two images in iphone apps
Combining images
As far as selectively replacing a specific color within a UIImage, that's a commonly asked question here:
In a UIImage (or its derivatives), how can I replace one color with another?
How to make one color transparent on a UIImage?

iTextSharp image keep pixel dimensions?

Lets say I have an image that has a DPI of 72 and a width/height of 100px/100px.
However when I add the image and render the PDF, the image that is displayed is bigger than 100px/100px. How can I ensure that the when adding the image to the PDF using iTextSharp that I keep the same pixel dimensions as the original image, in this case 100px/100px?
It sounds like you'll want to check out the ScaleAbsolute method of the iTextSharp.text.Image, which will explicitly set the height/width of an image. There are a couple of related methods you'll want to read up to: ScalePercent and ScaleToFit.
These methods are described in the SourceForge iTextSharp tutorial which includes samples. See tge "Scaling and Rotating the Image" section.