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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:20:57+00:00 2026-05-30T18:20:57+00:00

This is a code organization question. I have code that will put a gradient

  • 0

This is a code organization question. I have code that will put a gradient background on a view. I want to use this same code on multiple views – therefore, I want to put the code in a function and call it when I configure the views in question.

My question is, where is the correct place to put such a function? I’m very new to iOS development, and I’d like to start out doing things as cleanly and as properly as possible.

  • 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-30T18:20:59+00:00Added an answer on May 30, 2026 at 6:20 pm

    As mentioned before, Categories might be the best idea when it comes to DRYing up your code.

    Remember that, just for convention, categories in Objective-C are the name of the class you are writing the category for + the addition types.

    For example you could name your category files:

    UIView+Gradient.h
    UIView+Gradient.m

    Then you can call it up whenever you want in any subclass if UIView 😀

    I believe there is a template for this in Xcode 4.3 (for categories I mean) so go ahead and give it a try.

    Remember that you have to write a new method name, otherwise you’d be overwriting an existing method of UIView and that’s not what you want in this case.

    Cheers and congrats on your effort to learn proper coding habits from the start 🙂
    Kudos to you!

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

Sidebar

Related Questions

I have this code: string name =M; Expression<Func<Organization, bool>> getExpression1 = r => r.Name.Contains(name);
Had a question that I've often wondered about. Is it better to have multiple
Question: In terms of program stability and ensuring that the system will actually operate,
Our organization recently got TFS 2008 set up ready for our use. I have
This is perhaps not a question unique to Mercurial, but that's the SCM that
So I had a question on general organization of code for the Zend framework
Let me preface this question and state that using Entity Framework is not an
I wish that I had a more precisely descriptive title for this question, but
I'll preface this by saying that I usually work in C#/.Net. Normally, I use
This code in JS gives me a popup saying i think null is a

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.