prince prince -4 years ago 60
iOS Question

User can't able to enter amount before currency symbol in textfield in objective c



Below is an image of the screen, I just want to when the user enters the amount on this textfield then the user can't able to move cursor before $ sign and can't able to write amount before $ sign.

Please have a look on my problem, and give me idea about it,

enter image description here

Answer Source

Try to set currency image as leftview of textfield

For Imageview

    UIImageView *imageArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"currency.png"] ];
    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    [paddingView addSubview:imageArrow];
    imageArrow.center = paddingView.center;
    textfield.leftView = paddingView;
    textfield.leftViewMode = UITextFieldViewModeAlways;

For Label

 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    label.text = @"$";
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.rightView = label;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download