Rupee symbol in iOS - iphone

How do I add a rupee symbol in a UILabel on the iPhone?

Here is How I've done this by using Unicode Character It's working and tested by me.
NSString *rupee=#"\u20B9";
NSLog(#"print rupee symbol %#",rupee);
Please refer this link UniCode Character
For Swift Language you should try!
let rupee = "\u{20B9}"
println(rupee)
// for Swift >2.0
let rupee = "\u{20B9}"
print(rupee)
more about UniChar you should check this Official Apple Doc Cheers :)

Rupee symbol is available as part of the platform itself. Go to Edit > Special Characters > Currency Symbols.
When I used it first, I was under the impression that this is part of the menu options of Xcode, but right now while I am typing here on this page opened in Firefox and I go to Edit menu, I see the same Special characters option in the menu so probably it is part of OSX itself. Just drag and drop it anywhere on the storyboard where you want this symbol to appear. I'm just dragging and dropping the same here, let's see whether it appears here or not!
₹
This integration of special characters in osx is pretty handy and also has many variations for that special character (rupee symbol in this case)

Yups, Parth is right just copy and paste the rupee symbol (₹) to NSString and you are done.

In Swift 4
let RSlabel = UILabel()
let cost = 1000
override func viewDidLoad() {
super.viewDidLoad()
RSlabel.text = "\u{20B9}"+"\(cost)"
print(RSlabel,"RSlabel")
}

May be you will have to find some language which has a similar symbol.
Or you can just copy the Rupee symbol from somewhere (like from some soft-copy document which contains that) and paste it directly from there into your UILabel text.
As for now I don't know any other way apart from this as present keyboards dont have a Rupee symbol as yet. May be in future it would be having that :)
Hope this helps you

Go to
Edit -> Emoji & Symbols
In Xcode 7, the symbols location has been changed a bit from what has been suggested by Atul.

Go through the below SO post,
Localize Currency for iPhone
Edited:
you could also go with the approach of having rupee symbol as an UIImageView and show it before OR after a UILabel view.
Please see the reference code :
Have below in .h file...
UIView* iContainerView;
UIImageView* iRupeeSymbol;
UILabel* iAmountLabel;
And your .m file would be like below.
iRupeeSymbol= [[UIImageView alloc] initWithImage:myRupeeImage];
iAmountLabel.text = #"55555";
[iContainetView addSubview:iRupeeSymbol];
[iContainetView addSubview:iAmountLabel];
[self.view addSubview:iContainetView];
And set the appropriate frame value for all three views,

Related

text-align-last css property Swift Equivalent

What is the swift Equivalent for 'text-align-last' css property?
I prefer a codeless solution.
Here is what i have done and what i get:
The last line (sometimes the only one) is aligned to the left, which is inconvenient.
You need to change the label's text from Plain to Attributed, then you can paste any string and the alignment, as well as other attributes, will hold.
So basically any text style that can create on word processor application can be used here.
In the following example I've used pages (Mac application) to edit the text format as I liked and copied it to the label text box in Xcode.
Here is a picture of the simulator running the app:
While it is not possible to apply different aligns on a single label, if the last(and sometime only) line should be aligned to the right why not align the entire label to the right?
EDIT
If that doesn't fix you problem then I don't think it's possible to resolve without code.
In the case you do decide to write some code you could look into determining which is the last line of your string (maybe: How to get text from nth line of UILabel? ) and try to apply different formatting with AttributedString.
If that works then you can always subclass UILabel and override func layoutSubviews() to calculate this automatically for you. This way you won't have to think about it again!

Workaround Sought for: iOS 6 NSAttributedString Descenders Block Underline

I am using NSAttributedString (and NSMutableAttributeString) for writing to a PDF via UIGraphicsBeginPDFContextToFile. When I output an attributed string with underline attributes, the underline is broken when a letters descender goes over underline.
Here is a sample (screen capture) showing the current output:
And here is the code that builds that sample attributed string:
NSAttributedString* ftype =
[[NSMutableAttributedString alloc]
initWithString:#"Dangerous"
attributes:#{
NSParagraphStyleAttributeName:pstyle,
NSFontAttributeName:[UIFont fontWithName:#"TimesNewRomanPS-BoldMT" size:48.0],
NSForegroundColorAttributeName:[UIColor redColor],
NSUnderlineStyleAttributeName:[NSNumber numberWithInt:NSUnderlineStyleSingle]
}
];
My client's and my preference is that the underline be continuous, and ideally shifted below the descender.
Manually drawing the underline is difficult as we would have to computer the text position of the words after layout (sometimes the text is not as simple as the example above).
Does anyone have a fix to put the underline either a) lower or b) make it continuous?
Thanks in advance.
I know this was old and after searching found no answers. The solution I found is in the dictionary you pass in for attributes to NSAttributedString initWithString:attributes: add this
NSExpansionAttributeName : #-0.0001f
This scales the glyph, and it seems even with this small amount the underline doesn't get cut (well it didn't with the 13pt font I was using). Though this doesn't seem like the intended use of NSExpansionAttributeName, but couldn't find another solution.

How to put an arrow into a UILabel

Hi I'm trying to put an arrow into a UILabel's text but it is not working. I'm trying the following code
NSString *labeltext = #"➜";
label.text = labeltext;
But that makes the app crash!
(if you go to the edit menu and go to special characters then it is the 10th rightwards arrow)
.
Thanks for your help in advance
Code should be working by just writing the special character directly in the code as written in the question also
label.text=#"➜";
but in case it is not working then there are alternative ways to print the special characters in IOS, You need to use Unicode character of this sign , check out this page codes and after getting the code just do like as follows
UniChar ucode = 0x2794;
NSString *codeString = [NSString stringWithCharacters:&ucode length:1];
[label setText:codeString];
OR Just write directly like as follows
label.text=#"\u2794"; // this is the unicode for right arrow
in Swift:
lable.text="\u{2794}"

How to enter unicode characters in a UILabel in Interface Builder?

I would like to display a unicode character (the speaker symbol U+1F50A) in label.
Is it possible to enter this symbol in Interface Builder?
Yes, you can click "Edit" > "Special Characters…" — there you can find all unicode characters (including the emoji) and copy/paste them where you set the label text in Interface Builder.
EDIT:
In Xcode 6 it's "Edit" > "Emoji & Characters"
Xcode 7+: "Edit" > "Emoji & Symbols"
For those who tried doing it programmatically, but failed, just use this:
label.text = #"\U0001F50A";
Do it programmatically.
Declare an IBOutlet for the Label, with the means of NSString type:
// UTF-8 Hexadecimal Encoding
NSString *myString = [NSString stringWithUTF8String:"0xF09F948A"];
myLabel.text = myString;
Also, take a look at this question.
In Xcode 8/Swift 3 the easiest is to use the unicode escape:
let a = "\u{1F50A}"
It's fun why few people knew this.
You can enter Unicode-symbols directly by holding "Option" and entering hex digit.
All you need: (Sierra example)
goto "Preference -> Keyboards -> Input Sources" and search for "Unicode Hex". It should appears under "Others" section. Next add it and then you be able enter Unicode-char anywhere just selecting this input source.
For example: ✓ = (Alt+2713), € - (20ac), etc.
Most interesting section from 2100 to 2800.
Full list you can found here - Unicode table
P.S.: This method sutable only for four-digit Unicodes

iPhone how to write symbol on a label?

I am going to develop the iPhone app. But I got stuck with one place. I want to write some symbol on the label from the xib file.
The symbols are not on the keyboard but we can get it by the ASCII value.
e.g: the ACSII value for the character sign "mue" is 230 but how to print that symbol "mue" on the label that i dont know.
So please help me for that.
Thanks in advance.
Use whatever editor you like to produce that character, and open your xib in XCode and just copy/paste it in?
Use NSUTF8StringEncoding to encode your string.
For example,
NSString *str = [NSString stringWithUTF8String:"your string for encoding"];
[lblName setText:str];
Following function will also help :
- (NSString *) decodedString:(NSString *) originalString {
NSString *newString = [NSString stringWithUTF8String:[originalString cStringUsingEncoding:[NSString defaultCStringEncoding]]];
return newString;
}
I suggest to use above function.
Pressing Cmd+Ctrl+Space will open a special characters menu. Check if the desired symbol is present. If it isn't, click the gear icon, then select the desired category — add it to the list.
See screenshot below
I think you mean the character 'µ', yes?
If so, you can simply type it into the label by clicking "option" and "m" on your Macintosh keyboard, when you are editing the label in your XIB.
If you can use the unicode number instead, you can do it like this:
NSString *muString = [NSString stringWithFormat:#"%C", 0x03BC];
Write 0x then the unicode number.
Open the "Special Characters"-Panel and search for your character. You can find it at the bottom of the edit menu. There is a shortcut for it too, cmd+opt+t
Copy and paste your character from there to your UILabel.
and btw: option + m = µ
You can simply type into label by using 'Alt' key + 'm' key on key board, when you are editing the label in your XIB and rest of symbols, you can get easily using 'Alt' key and other keys. You can fix 'Alt' key and change other keys(one by one).