What is Pegasus?

Pegasus is a lightweight open-source framework that allows you to build user interfaces for your Cocoa Touch projects in XML.

You can grab Pegasus from GitHub here.

Why would I want to build my interface in Pegasus?

If any of these are true…

  • You come from a web development background and prefer to design interfaces in markup.
  • You can’t stand the Interface Builder workflow.
  • Your app needs to create UIs on-the-fly at runtime (for example, downloaded from a web server).
  • You’re a designer, or have a lot of designers on your team, who you want to have design UIs without programming experience.
  • You want to create a common UI that scales on both the iPhone and iPad screens.
  • You’re not comfortable writing your own UI programmatically, or just find it too much work.
  • You’re just looking for a simpler, quicker and more intuitive way to quickly build UIs.

…then Pegasus may just be perfect for you. It’ll save you a lot of work, too!

For example, if you wanted to create a simple UIView which contains a UIImageView, UITextField and UIButton, here’s what it looks like in Objective-C:

        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
        imageView.frame = CGRectMake(10, 100, 300, 50);
        [view addSubview:imageView];
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 300, 240, 40)];
        textField.placeholder = @"Enter text";
        [view addSubview:textField];
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 20, 40)];
        [button setTitle:@"OK" forState:UIControlStateNormal];
        [view addSubview:button];

I’ve even been fairly conservative and tried to use compound statements where possible, and the code is still fairly unwieldy and difficult to read. These issues are exacerbated when dealing with a multi-level view hierarchy where it can become extremely difficult to refactor the view.

Instead, the same view could be built in Pegasus as follows:

<LinearLayout frame="fill_parent" padding="10">
	<ImageView height="300" width="50" image="image.png" />
	<TextField height="240" width="40" placeholder="Enter text" />
	<Button height="20" width="40" title="OK" />

It really is as simple as specifying each view as a tag and nesting tags to specify subviews. Each XML corresponds to a UIKit property. Almost all properties are supported, and Pegasus even includes additional totally awesome features that will improve your coding experience:-

Layouts can be deployed which automatically lay out your views at runtime, meaning that you don’t need to individually position each view.

Translators are used by Pegasus to translate your string attribute values into their corresponding UIKit structs/enums/primitives/objects. For example, the string "{{0,0}, {320, 460}}" needs to be translated into its CGRect equivalent. But while I was coding that, I decided to add some treats here. For example, for UIColor you can now specify any preset color name (e.g. "blue", "green", …) or even a hex value just like you would in HTML (e.g. "#ff00cc")!

Virtual Properties can be used where a class doesn’t quite provide the property that you want, so I created some “virtual” properties to add that missing functionality. For example, to set a UIButton‘s title, you should be using setTitle:forState: which can’t be set using a property. But given that most people just want to set a title for UIControlStateNormal, I created a virtual property called “title” which overrides the default Pegasus attribute-to-property mapping and calls the relevant method for you.

For further information, please consult the Pegasus wiki.

96 Responses to “Pegasus”

  1. Dannie says:

    Personally I think that Seton Hall is going to be among the first teams overlooked of
    this decades class. A portion off them is burieed within the
    surface or various other form of earth or dust.

    Feel free to visit my blog post :: march madness 2014

  2. Thorsten says:

    Due to this, some business employers find it harder to cope with the changes.

    Onne further thought: you do not possess to like your defense lawyer.

    Check out my blog:

  3. Nelle says:

    The first and foremost issue that needs to be donne iss
    to store food properly. Some may have yett another sleep within the main cabin.
    It’s a very dangerous type of shape, and might have serious health threats.

    Feel free to visit my homepage …

  4. Ashli says:

    Consider what yoou want to use the lump-sum money for.
    Becsuse of the tax free feature they’re allso quite profitable
    investment devices. The IMF stated that Zimbabwe was under debt anxiety.

    Also visit my blog post ::

  5. Wilhelmina says:

    Great weblog here! Also your web site so much up very fast!

    What web host are you using? Can I get your associate hyperlink in your host?
    I wish my website loaded up as fast as yours

    Here is my web site: Procurve Wireless

  6. Chassidy says:

    koenzym q10 gal. What Fish Oil And Coq10 Can Try To Keep
    Your Heart Healthy

    My web site :: gdzie kupic chlorelle

  7. Crystle says:

    Must Study Leadership Book and kursy forex na zywo.
    Must Study Leadership Book

    Visit my web site; nauka forex cargo

  8. Faustino says:

    This is a topic which is close to my heart…
    Best wishes! Exactly where are your contact details though?

    Here is my weblog – jezyk angielski

  9. Angie says:

    And what’s more, you would be the explanation of others falling in value.
    Quality toddler beddjngs and blankets accomplish the job quite correctly.

    Sometimes the best you can is not lose investment.

    Here is my web site …

  10. Stefan says:

    The Good The installation of New Substitution Windows and
    forex trading for dummies

    My web site …

  11. Jeffry says:

    I am a dye queen, and I’m always changing with the times of
    year. Moreover, learning to play soccer with the inexperienced
    coaches could extend to serious issues. Away these resume resources and sample resumes.

    Feel freee to visit my website – summer camps boston

  12. James says:

    Everyone hears about those stocks that possess a 10% dividend yield on the other hand don’t know what they actually are.

    Read the paid newsletters will stay know as a precaution have become into.

    Also visit my web-site :: Michael Manis

  13. Dewayne says:

    Using internet plans, you will only need to set up your Google account and
    buyild some ads. The Google Earth Web version is free to make
    use of on the Internet. Case 1+1= then hit enter Goolgle
    mayy answer this for you!

    Visit my page; torrence Boone enfatico

  14. Angie says:

    Historically governments have inflated their way out of debt.
    Particularly crucial when talking of penny stocks.
    Suncor Energy closed at $42.80, up 0.66% onn his or her day.
    Buy a CD in your child’s name whenever realistic.

    My website Michael Manis

  15. Alisia says:

    Every bit of the camps are not run by professionals. Suppose, really like outdoor adventures and sports, sports camps can be thee alternative for
    your interests. Don’t just writye down something but actually work on there.

    Feel free to visit mmy web-site; Walter Synalovski

  16. Jared says:

    The following family friendly Idaho roadsde attractions in order to part virtuually any road trip.
    These pretty flowers grow to 2 feet tall and blossom during the summer and fit.
    Before Steer Montanas dath a local rancher, Mr.

    My weblog; Autovantage (

  17. Alisia says:

    Ikea instructions once can be found in “observe and do” image-only structure.
    A retailer’s Home Inspection may emphasise troublesome
    areas whioch range from safety dangers to property damage.

    Herre is my blog post … Salt Lake City Home Inspector

  18. Mauricio says:

    You’ll must be abl to run a smzll business if you have a muxh any kind off success.

    Lilian paid the realtor $ 1478.00 for first month and a deposit.
    Being a Realtor can be quite a good job.

    my blog post …

  19. Rickey says:

    This is mimiced by what undertaking on a construction website?
    Don’t skimp on components or jobb whhen developing a garden fish ond that’ll last for quite
    a while. You will find currently 430 employeed in Rockford.

    Also visit my blog

  20. Philomena says:

    Time is opportune to shift towards the standing of the car owner
    currently. Youngsters could race Cars applying Disney Caars race track games made.

    The Cars magnets include three in a deal.

    Check out my web site

  21. Dorcas says:

    She shares guidelines extensive expertise, advice and in her work
    at home Group and Blog. Within Georgia, real estate professionals are required by their bbrokers to ofcfer out 3 titles
    of personnel.

    Feel free to suhrf to my site :: Home Inspection Pittsburgh

  22. Vallie says:

    MLS listing increase your profile online and provide you with a greater mrketing program.
    We have offered a much better knowledge to more of our pupils then nowadays we do.
    There are plenty of outdoor activities to-do.

    Look at my homepage Http://Www.Quora.Com

  23. Harold says:

    Can he enable you to go with him while hee does the
    examination? There’s you should not visit too many or too few items.

    Inspections inform you wjat you get for the money.

    Do You Knnow There’s a Job Looking For You!!!

    Look into my page; http://www.houzz.Com/pro/indianapolishomeinspection/home-inspection-all-star-indianapolis

  24. Hung says:

    The chosen region has to be competent tto handle the dstruction due to the dumpster.

    My web blog: chicago dumpsters rental

  25. Frieda says:

    Be fmiliar with what you need before you sfart looking for ‘your’
    perfect dwelling. On average, new homes are
    about 700 sqft bigger than homes built-in the 1980′s. Takee advantage of all
    support that’s offered to you.

    Feel free to surf to myy homepage xing

  26. Kellee says:

    Being Truly A Realtor could be a good vocation.

    There’s lots of family-fun and attractions in Charlotte.
    One of the reasons to choose tis market is due to the substantial experience of our

    My blog post :: real estate jobs los angeles

  27. Josefa says:

    Youur dog doesn’t require an entire dog biscui to get a handle.

    Finance proves to be an obstacle inside their
    way, whenever A student decides to follow education.
    No ego should be possessed by the teacher.

    My blog post Tracy Rexroat

  28. Ignacio says:

    These products tastes great and it does work. This means that ass soon as a person back on
    carbs, you might bbe bigger pror to now.
    It isn’t a quick fix or a diet it’s a solution.

    my blog post: Weight Loss

  29. Logan says:

    I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored subject matter
    stylish. nonetheless, you command get got an nervousness over that you wish be
    delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this increase.

    Here is my site :: Can You Get Pregnant Right Before Your Period []

  30. Isis says:

    As the admin of this site is working, no uncertainty very rapidly it will be renowned, due to its
    feature contents.

    Feel free to surf to my weblog :: web trick mobile games

  31. Ivey says:

    Torba na komputer wzór and urolog szczecin prywatnie.
    Torba na komputer wzór

    My web blog: medicus urolog szczecin

  32. Lavern says:

    I drop a leave a response when I especially enjoy a post
    on a website or I have something to contribute to the conversation.
    Usually it’s a result of the sincerness communicated in the article I browsed.

    And after this post Jonathan Ellis ? Pegasus. I was moved enough
    to leave a thought ;) I actually do have a couple of questions for you if it’s allright.

    Could it be just me or does it look as if like some of the responses look like
    they are coming from brain dead visitors?
    :-P And, if you are writing on other social sites, I’d
    like to keep up with anything fresh you have to post. Could you list every one of all
    your community pages like your linkedin profile, Facebook page or twitter feed?

    Also visit my site; clash of clans hack android

  33. Vito says:

    Hi, this weekend is nice in support of me, as this time i am reading this
    great educational post here at my residence.

    Here is my weblog – telecharger photofiltre

  34. Zachery says:

    I’ve learn some good stuff here. Definitely value bookmarking for
    revisiting. I surprise how a lot effort you set to make this sort
    of fantastic informative website.

    My web site … Clash Of Clans Hack Android

  35. Mary says:

    Swimming Pool Supplies; Added Benefits And Drawbacks and dlaczego spirulina.
    Swimming Pool Supplies; Added Benefits And Drawbacks

  36. Elizabeth says:

    No honest attorney would promise you a result. However, you is not able to represent
    another certain unless you really are licensed attorney.

    my web blog – russell rusty hensley

  37. Patti says:

    You’ve to appreciate the work! teaching is not for the faint of heart.
    Prewsent him visual helps and let him mix that with alll the memorization for the best effects.

    For this reason these scams work so nicely.

    my blog post;

  38. Hong says:

    If Punkbuster catches you running one of these programs, you is going to be kicked out with the game.

    The on the job simply refers to the two separate controllers for both your throttle control along
    with your axis controls for ailerons, elevator and rudder controls.
    A few Black Friday Countdown deals may also be found inside
    following link from Amazon.

    Also visit my web blog … battlefield 4 download

  39. Tracee says:

    This is my first time pay a visit at here
    and i am genuinely pleassant to read everthing at alone place.

    Look into my homepage :: watch or download belle

  40. Fidel says:

    Heya are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started
    and create my own. Do you require any html coding expertise to
    make your own blog? Any help would be really appreciated!

    My blog post; frozen movie free

  41. Pansy says:

    I read this paragraph fully about the comparison of most recent
    and preceding technologies, it’s amazing article.

    Feel free to visit my blog post … rust cheats

  42. Candelaria says:

    I’m not that much of a online reader to be honest but your
    sites really nice, keep it up! I’ll go ahead and bookmark your site to come back down the road.

    Many thanks

    Here is my page: telecharger pdf creator

  43. Aileen says:

    Why viewers still make use of to read news papers when in this technological
    world everything is accessible on web?

    my website: the amazing spider-man 2 full movie online free

  44. Darell says:

    What’s up it’s me, I am also visiting this web site on a regular
    basis, this web page is really pleasant and the visitors are actually sharing nice thoughts.

  45. Eula says:

    Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is fundamental and all. However imagine if you added some great images
    or videos to give your posts more, “pop”! Your content is
    excellent but with pics and video clips, this blog could definitely be one of the
    most beneficial in its field. Very good blog!

    my site: how to play piano despite years of lessons,

  46. Omer says:

    We can have many practical benefits in our lives with regard to information that
    can be helpful to us in a practical, quotidian fashion.

    One reason why it may have been more difficult for us in our contemporary Western culture to work with our intuition, aside from the fact that it hasn’t been valued in our culture, is
    that it often works in a different way from our normally
    used and encouraged faculties. Billboard’s Future – Sound
    conference will bring together musical artists, entrepreneurs, investors
    and meaningful rights-holders for focused conversations about next-generation opportunities in music
    over two days in San Francisco from November 17.

    Here is my web blog … PSI Seminars

Leave a Reply