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 7437447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:24:04+00:00 2026-05-29T10:24:04+00:00

How do you make methods that work across multiple views? For example. I created

  • 0

How do you make methods that work across multiple views? For example. I created this:

- (void)setPageTitle:(UILabel *)title withText:(NSString *)text
{
    UIColor *pageTextColor = [UIColor colorWithRed:18.0/255.0 green:79.0/255.0 blue:118.0/255.0 alpha:1.0];

    // Set page title
    UIFont *font = [UIFont fontWithName:@"PassionOne-Regular" size:23];
    [title setFont:font];
    [title setText: text];
    title.textColor = pageTextColor;
    title.shadowColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
    title.shadowOffset = CGSizeMake(0, 1);

    CGRect titleRect = [title textRectForBounds:title.bounds limitedToNumberOfLines:999];
    CGRect tr = title.frame;
    tr.size.height = titleRect.size.height;
    title.frame = tr;
}

I want to be able to call the setPageTitle method on UILabels within different views. How do I go about doing this? Where do I put this code to make it work? I only want to put it in 1 file and have it work in different views. Thank you.

  • 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-29T10:24:05+00:00Added an answer on May 29, 2026 at 10:24 am

    I would suggest making this a category on the UIView class.

    UIView+PageTitle.h

    @interface UIView (PageTitle)
    - (void)setPageTitle:(UILabel *)title withText:(NSString *)text;
    @end
    

    UIView+PageTitle.m

    #import "UIView+PageTitle.h"
    @implementation UIView (PageTitle)
    - (void)setPageTitle:(UILabel *)title withText:(NSString *)text {
        // your implementation
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i make an extension method that will work like this public static
I'm trying to make the BinaryFormatter work across different versions of my assembly. The
I want to make a method that takes any file and reads it as
I'm trying to make a method that returns a string of words in opposite
I am trying to make a method that will go through a list of
I'm trying to make a method that will tell me weather or not it
I am trying to make a method that tests to see if 3 lengths
I want to make an interface in C# that defines a method that always
In C# you can make a block inside of a method that is not
I have a method: myMethod() {} that I want to make accessible to javascript.

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.