Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6390413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:32:44+00:00 2026-05-25T03:32:44+00:00

Hello friends, I want to add a custom button on my searching string like

  • 0
Hello friends,

I want to add a custom button on my searching string like iPhone text.

Is there any way to develop this functionality or any idea?

Here is my code.

     - (void)viewDidLoad {
        [super viewDidLoad];

        self.title = @"Label Navigation Demo";

        [self dynamiclabel];
    }


    -(void)dynamiclabel
    {
        dlabel = [[DynamicLabel alloc] initWithFrame:CGRectMake(30, 50, 300, 20)];

        NSString *labelText = @"Choose a topic from the left to find answers for your questions about iPhone For the latest downloads, manuals, and other resources for iPhone choose an option below.";
        NSLog(@"Label Text:--->%@",labelText);

        [dlabel getSize:labelText FontName:LABELS_FONT_NAME_BOLD FontSize:12.5f label:dlabel];
        dlabel.textColor = FONT_GREEN_COLOR;
        dlabel.backgroundColor = [UIColor clearColor];
        NSLog(@"Dynamic Label Height:--->%f",dlabel.frame.size.height);

        //[self findAllLocationsOfString:@"iPhone" sourceString:labelText];

        [self.view addSubview:dlabel];

        //Search String in Label Text
        //NSString *str = @"Choose a topic from the left to find answers for your questions about iPhone For the latest downloads, manuals, and other resources for iPhone choose an option below.";
        //NSString *str = [NSString stringWithFormat:@"%@",labelText];
        NSInteger count = 0;
        NSArray *arr = [labelText componentsSeparatedByString:@" "];
        for(int i=0;i<[arr count];i++)
        {

            if([[arr objectAtIndex:i] isEqualToString:@"iPhone"])
            {   
                NSLog(@"%@ %d",[arr objectAtIndex:i],i);
                        CGRect buttonFrame = CGRectMake(i, 

                                             dlabel.frame.size.height + i, 

                                             dlabel.frame.size.height + i,

                                             i);

            //CGRect buttonFrame = dlabel.frame;
                       //buttonFrame.size.height = dlabel.frame.size.height-i;
                      //dlabel.frame = buttonFrame;

            NSLog(@"Button Frame:--->%@",NSStringFromCGRect(buttonFrame));
            [self buttonWithTitle:@"Hello" target:self frame:buttonFrame];
            }
            count++;
            NSLog(@"Count:-->%d",count);

        } 

    }

    - (UIButton *)buttonWithTitle:(NSString *)title target:(id)target frame:(CGRect)frame {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = frame;
    NSLog(@"Button Frame in Function:--->%@",NSStringFromCGRect(button.frame));
    [button setTitle:title forState:UIControlStateNormal & UIControlStateHighlighted & UIControlStateSelected];
    [button addTarget:target action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundColor:[UIColor clearColor]];   // in case the parent view draws with a custom color or gradient, use a transparent color
    [self.view addSubview:button];

    return button;
}

Thanks in advance.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:32:44+00:00Added an answer on May 25, 2026 at 3:32 am

    If you want to create a “link” on some custom text in your label, instead of using a WebView as @Fabian Kreiser suggested, you sould use my OHAttributedLabel class (you can find it on GitHub here or search the term on Stackoverflow, it is mentionned by other posts too), which is able to display NSAttributedString and add hyperlinks to it.

    See the sample code provided on my github repository: you can use my addCustomLink:inRange: method to add a link (with a customized URL) to a range of text (range that you could determine by iterating over every occurrences of the word “iPhone” in your text very easily). Then in the delegate method on OHAttributedLabel, you can catch when the link is tapped and act accordingly to do whatever you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Friends I want to know is there any way we can open or
Hello friends can you tell me how to make style of button like hyperlink.
Possible Duplicate: iPhone development on Windows Hello friends, I Want To Know that Is
Hello friends i want to add more effects on my div when i click
hello friends i am trying to get a list of user id and want
Hallo friends, I want to figure out the following problem: Suppose,we have expression like,
Hello friends i am a total beginner in c#. I want to read numbers
Hello friends I am trying to add a class to body dynamically depending on
Hello Friends I want to upload a image but according to requirement when click
Hello friends a newbie question... The Issue is like this: I have a static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.