How to Quickly Make a Brochure In Microsoft Word Using a Template

Don’t be overwhelmed by the task of creating a brochure to promote your business. You can quickly and easily create a professional brochure in Microsoft Word using templates.

tri fold brochure template word
You can find tons of great brochure templates for Word on Envato Elements and GraphicRiver.

In this tutorial, I’m going to show you how to make a brochure in Microsoft Word, using a Microsoft Word brochure template. First, though, let’s look at why it makes sense to use brochure templates.

Why Printed Brochures Are Important

With so much information available online, are printed brochures still relevant for entrepreneurs, small businesses owners, and marketers? 

Yes, they are, and here are just a few reasons why. 

Ever been to one of those networking events designed to grow your business? I have, too, and it can be kind of a zoo. By the time you’ve visited the first dozen booths, you can barely remember your own name, let alone what each booth presented. 

If you’re exhibiting at a trade show or networking event, handing out a brochure will help people remember your business later. It’s one of the best ways to make sure that when you’re out of sight of your prospective customer, you don’t have to be out of mind.

brochures can help with networking
Brochures can be helpful when you’re networking or at a conference. (Image source: Envato Elements)

That’s also why it’s a good idea to have brochures available at conferences, workshops, seminars, and training sessions. At these events, people pick up brochures so they can retain business and contact information. Sure, you could hand out a business card, but a brochure offers much more. They’re a great way to deliver a focused, targeted message about your business. 

Even if you’ve got a website, there’s no guarantee that visitors will experience it the way you want them to. So it makes sense to have a brochure, too. 

And there’s one more thing: brochures last. Even if the person who picks it up doesn’t act, that person may pass it on to someone else, or leave it where a third person can find it. That means long after a particular event, that content is out there marketing your business.

The bottom line: brochures can help reinforce your brand so that people recognize and remember your business.

But there’s one problem you  might face as a small business owner: knowing how to make a brochure. In the past, creating brochures required design and layout skills, so most were created by graphic designers. 

The good news is: that has changed. You can now create brochures and pamphlets easily using the software you’ve already got on your computer: Microsoft Word. According to statistics from Datanyze, Word is one of the most-used document software programs.

Benefits of Using Microsoft Word Brochure Templates

There are several benefits to using brochure templates in Word. 

One of the main ones is that you don’t need design skills to create a stunning brochure. Templates let everyone benefit from good design without having to come up with the concepts. 

There’s no need to learn complicated page layout software or use complex apps, either. If you’ve never created a page layout before, using a program like InDesign can be challenging. Using brochure templates removes the hassle, by giving you a layout that’s easy to customize.

Then there’s speed. If you need to create a brochure in a hurry, a brochure or pamphlet template with placeholder text and images lets you create an attractive marketing tool in just a few minutes. 

What You’ll Need to Customize Your Template

Brochures are basically text and images, so you’ll need plenty of both to customize brochure templates in Word. While you can do this as you go, it’ll work better if you prepare your text in advance, and choose some images, too. Don’t worry; you can always tweak as needed later.

Since brochure copy is marketing copy, you’ll need:

  • a main title
  • an explanatory subhead
  • subheadings for the main content sections
  • text
  • a call to action
  • contact details
  • images for visual impact

For example, your copy might include

  • your main unique selling point (USP)
  • a brief history of your business
  • an introduction to your services or products

Here’s some more advice on writing your own copy. Now let’s get started on making a brochure in Word.

How to Create Brochure Using a Template

Once you’ve got your content ready, it’s time to choose a brochure template for Word so you can create your brochure. Word has a built-in template library, but sometimes it’s hard to find a design that really appeals.

So, if you want an even wider range of templates to choose from to suit every business need, explore the brochure design templates at Envato Elements and GraphicRiver. These online marketplaces have thousands of Microsoft Word brochure templates and pamphlet templates to choose from.

For example, here’s how you find a Microsoft Word brochure template on Envato Elements. Go to the website. Select Graphic Templates to the right of the search box so you’re only searching for templates. Type “brochure, microsoft word” in the actual search box. There will be thousands of templates to choose from. 

Microsoft Word brochure templates at Elements
At Envato Elements you can download an unlimited number of Microsoft Word brochure templates (and other creative assets) for a low monthly fee.

Use the filter boxes on the left to refine your search by orientation, color, format, and more. There are several brochure types to choose from, including bifold, trifold, booklets, and flyers. Learn more about the different brochure types in the tutorial, How to Make a Brochure. 

When choosing a brochure or pamphlet template, make sure it has a good balance of text and images, so it’ll be visually appealing. You also want to ensure it fits in with your company branding, so pay attention to color, too.  Remember, it has to stand out against other brochures and encourage people to pick it up. Keep this in mind as you select your template.

I’ve chosen a tri-fold brochure for this tutorial, which is commonly used by small businesses, and works for most uses. Here’s the template we’re going to use:

1. Download and Unzip the Template

If you already have an Envato account, then add your chosen template and get ready to use it. You’ll find it in the Downloads section of your account. Download the zip file.

Click on the file to unzip it, then go to the unzipped folder. Navigate to the Microsoft Word sub folder. 

microsoft word subfolder

There will be two versions of the template: Microsoft 97-2002 and one for the latest version of Word. 

template versions

Click on one of the templates to open it in Word.

If you’re using a recent version of Word, it’ll open in Protected View. Click where indicated on the notification to enable you to edit the template. 

word protected view

Before you go any further, click on File – Save As in the Word menu, and give your brochure a suitable name. You’ll work on this version from now on, but the original template will be there should you wish to use it again.  

Now it’s time to start customizing it. As you work through this tutorial, remember to save your work at regular intervals so you don’t lose your progress. 

2. Explore the Brochure or Pamphlet Template

Before you start customizing, get familiar with your template, so you know exactly where you’ll be adding text and images. This template contains two pages, each divided into three to make a trifold brochure. 

When printed, the second page will be on the rear of the first. The front cover is to the right of your screen, with the back cover in the middle. This ensures that when it’s folded the most important information is visible no matter how the brochure is placed. 

Now you’re ready to customize the Microsoft Word brochure template.

3. Replace the Placeholder Text

One of the easiest places to start customizing is to replace your company name wherever it appears in the template. To do this, double click on the text you want to change to highlight everything within the text box.

replace placeholder text

Then replace it with the name of your company. 

personalize the brochure

Repeat this process wherever the company name appears in the template. 

Use the same process to edit the company address and contact details, and the company website.

Next, follow the same process to edit the brochure title. Here’s how the original title looks:

original trifold brochure title

Choose something that’ll appeal to your target customer. For example, in this template, we’ve used the business strapline as a brochure headline.

making a brochure in word headline

You can also resize the text box to ensure that your text fits within the right space. Double click on the text to see the text box handles, then drag till it fits in the right space.

trifold brochure template headline

Depending on the text you want to use, you may need to adjust the font size. To do this, select the text you’ve just typed, and go to the font size selector near the top left of the screen. Choose a font size that works better for your template. 

Choosing a font size

Now it’s time to edit the main brochure text. Follow the process we used earlier to add new text to the back of the brochure. 

edit brochure text

Feel free to edit the headlines to suit your purpose. For example, we’re going to replace the “Case Study Trifold” headline with one that says “My Customers Say,” then add some testimonials to the brochure. Here’s how it looks in the original Microsoft Word trifold template:

brochure template word original

And here’s the edited version:

edited brochure template word original

4. Replace the Image Placeholders

To complete the front of the brochure, you’ll need to upload some suitable images to accompany the text. Since images tend to draw the eye, and give a first impression of your business, it’s essential to  make these as appealing, clear, and relevant as possible. 

To change a picture, double click on one of the grey photo boxes to bring up the drawing tools menu.

how to make a brochure replace image placeholder

Navigate to shape fill and select Picture. 

You’ll get the option to choose a picture that’s already on your computer. 

inserting a picture

Select the picture and it’ll fill the shape. 

If you need to find suitable pictures, type your search terms into Envato Elements. 

Use the filters at the side of the screen to refine your search by picture orientation, color, and more. For example, we’ve chosen portrait orientation to match the shape of our image placeholder boxes.

envato elements

In this case we’ve chosen a typewriter image. Here’s how the template looks with a couple of pictures added:

customized trifold brochure

5. Customize the Inside Pages

Now that the outside is done, repeat the process for the internal pages, replacing text and images as shown earlier. 

If there are elements you don’t need on the template, you can delete them, as we’ve done with the numbers on this image. 

customize a brochure in word

First, highlight the text and press Delete. Then click on the text box, right click, and press Cut.

Here’s how the cleaned-up image looks.

6. Proofread

Before you print your trifold Word brochure, proofread it and check for any mistakes. Spelling and grammar errors make your business look unprofessional, so you definitely want to avoid those. If you’re not confident in your proofreading skills, think about hiring a proofreading service. 

And look over the finished brochure to make sure all images are clear and in the right place. Remember, brochures can be around for a long time, so make sure yours is giving the right impression of your brand. 

Create Your Own Trifold Brochure From a Word Template

Now that you know how to create a brochure in Microsoft Word from a template, you’re ready to create your own professional brochure. Why not get started by downloading a Microsoft Word brochure template from Envato Elements or GraphicRiver today?

{excerpt}
Read More

How to Make an Event Flyer for Martin Luther King Jr. Day

Final product image
What You’ll Be Creating

Looking for your next promotional material? In this tutorial, we create an MLK flyer design that can double as a flyer template for any future events. 

Whether you’re a designer or not, this tutorial on how to make a flyer is easy to follow. Event flyers are great for promoting upcoming social get-togethers, and this one is great if you want to keep it as a template. In this tutorial, we will look at basic tools in Adobe InDesign to create a flyer. You will see how easy it is to customize and change up the images for future use. 

Don’t have the time and need a flyer right away? Take a look at our amazing InDesign Flyer Templates and other InDesign templates over at Envato Elements or GraphicRiver.

What You Will Need

You’ll need access to Adobe InDesign and Adobe Illustrator—if you don’t have the software, you can download a trial from the Adobe website. You’ll also need these assets:

Download the assets and make sure the font is installed on your system before starting. When you’re ready, we can dive in! 

1. Setting Up a New InDesign File

Step 1

In InDesign, go to File > New. Name the document MLK event flyer. We will create a Letter size brochure template. Set the file to the following dimensions:

  • Width to 8.5 in
  • Height to 11 in 
  • Orientation to Portrait
  • Uncheck Facing Pages
  • Margins to 0.5 in 
  • Bleeds to 0.125 in (it’s best to seek your professional printer’s preference).

Click Create.

Create a new InDesign file

Step 2

Before we start with the design, let’s organize the color swatches. This step is essential if you want to keep this flyer as a template for future use. Head over to Window > Color > Swatches to expand the Swatches panel. Select the default swatches, Right-Click > Delete Swatch.

Choose New Color Swatch button from the main menu. Add the following colors:

  • Blue: C=0 M=90 Y=100 K=0
  • Red: C=100 M=60 Y=0 K=80

Click Add after you input each color value. Click Done.

Add color swatches

2. How to Add Typography in Your Flyer Design

Step 1

On the toolbar, select the Rectangle Tool (M). Click on the document and set the Width to 8.75 in and the Height to 11.25 in.

On the Swatches panel, set the color to blue. This will be the background of the flyer, and in order for it to stay put, we will lock it. Select the rectangle and press Command-L to Lock. To Unlock, press Option-Command-L.

Create a rectangle as a background

Step 2

On the toolbar, select the Polygon Tool. If you can’t see it, hold click on the Rectangle Tool button and select the Polygon Tool from the dropdown menu. Click on the document to open the Polygon option window. Change the settings to the following:

  • Polygon Width: 1 in
  • Polygon Height: 1 in
  • Number of Sides: 5
  • Star Inset: 50%

Click OK.

On the Swatches panel, set the color to [Paper].

Create a star using the polygon tool

Step 3

We want to create a row of stars, so we will be duplicating the object multiple times. Select the star and Right-Click > Transform > Move. In the Move option window, set the Position Horizontal to 0.25 in. Click Copy. 

Using the move option duplicate the star

Press Option-Command-4 to Transform Sequence Again. Repeat this action until you’ve created a row of stars that fits within the margins of the flyer.

Select all the stars and group them by pressing Command-G. To Ungroup, press Option-Command-G. We will use these stars later, so let’s move them downwards.

Create a row of stars by transforming the sequence

Step 4

Select the Text Tool (T) from the toolbar. Draw a text box that fits from margin to margin. Add a copy—in this case, we can add the name of an organizer. 

Head over to the Control bar and set the Font to Config Alt, Font Family to Bold, Size to 10 pt, and the text box to Align Center. You can also do this by going to the Character panel (Window > Type & Tables > Character Panel) or Paragraph panel (Window > Type & Tables > Paragraph Panel).

Using the text tool add the new of the organizer

Step 5

We will use some of the stars to go on each side of the text. Using the Direct Selection Tool (A), select seven stars from each side of the row. Hold down Shift to make multiple selections. 

Press Command-C to Copy and Command-V to Paste. Press Command-G to Group the new set of stars and place them on the text. 

Using the direct selection tool select 7 stars from each side of the row of stars Duplicate to position on each side of the text

Step 6

Select the Text Tool (T), and draw a text box that fits the width of the margin. In this case, let’s add the name of the event. Using uppercase letters, add Martin Luther King Day. Divide the text into three lines. 

Head over to the Control bar and set the Font to Config Alt and the Font Family to Extra Bold. Set the Size to 120, the Leading to 92 pt, and the Tracking to -20. Set the paragraph to Align Center.

Add an event title

Step 7

To convert the text into an image frame, we need to convert it to outlines first. Select the text box, and head over to Text > Convert to Outlines. Press Shift-Command-G to Ungroup the text. Head over to the Pathfinder panel and press the Add button.

Convert to outlines ungroup and use the add pathfinder button to convert into a frame

Step 8 

Locate the Vintage American flag background .jpg file and open it in Adobe Photoshop.

On the Layers panel, select Create New Fill or Adjustment Layer > Brightness/Contrast. Double-click on the layer thumbnail circle to open the Properties panel. Set the Contrast to 100. 

open the flag image in photoshop and add a contrast layer

Step 9

Press Command-S to Save the file. Save a .psd or .tiff format—these two hold a better image quality. It is also useful if you would like to keep editing the image later. Click Save. 

Save the file as a psd or tiff file

Step 10

Let’s go back to the InDesign file. While selecting the text, press Command-D and find the Vintage American flag background in .psd form. Click Open. 

Using the Direct Selection Tool (A), select the flag image. Head over to the Control panel and activate the Constrain Proportion for Scaling button. Set the Percentage to 60%. Position the flag to show only the red parts through the letter. The reason behind this is to make the text readable. 

In the image below, you can see that I’m using the right-hand side of the image.

On the ID file select the text and place the image

Step 11

Using the Text Tool (T), draw a text box under the main title that fits the width of the margin. For this tutorial, I will be adding “Walk & Celebration” in uppercase letters. 

Head over to the Control panel and set the Font to Config Alt, Font Family to Semi Bold, Size to 40 pt, and Tracking to 120. 

Add a subtitle or a tagline to the title

Step 12

We will be using this text as another frame. Press Shift-Command-O to Create Outlines. Because this text is on a single line, we don’t need to repeat the process of grouping and ungrouping as in the main title.

Press Command-D to Place an image. Select the flag .psd file and click Open. 

Because the text is smaller, we need to make it as legible as possible. Select the image with the Direct Selection Tool (A). Head over to the Control panel and set the Rotation Angle to -10°. Using the arrows on your keyboard or your mouse, move the image until you are able to find the cream-colored parts of the image. Below, you can see the flag image outlined in brown.

Convert the text into outlines and place the flag image

Step 13

Using the Text Tool (T), add two text boxes to include the time and address of the event. Set the time to Bold, and set the Size to 40 pt and the Tracking to -25. Set the address Size to 15.5 pt. Place both of these text boxes next to each other, leaving a gap in between.

Using the text tool add a time and address of the event Leaving a gap in between

Step 14

Duplicate the stars row by pressing Shift-Option and dragging. Place one row over the time and address and the other below. This is where the Smart Guides (View > Grids & Guides > Smart Guides) become useful as they will let you know about the even space between the objects. 

Duplicate the row of stars and place on top and bottom of the text

Step 15

Using the Polygon Tool, draw a star to fit between the time and address. Click on the document to open the Polygon option window. Set the Width and Height to 0.2 in. Set the Number of Sides to 5 and the Star Inset to 50%. Click OK.

On the Swatches panel, set the Color to [Paper]. 

Using the polygon tool create a star to add in between the gap of the time and address

3. How to Create a Round Photo in Your Flyer Design

Step 1

Head over to the toolbar and select the Ellipse Tool (L). Click on the document to open the Ellipse option window, and set the Width and Height to 1.4 in. Click OK. You can use any color as we will be filling it in with an image later on.

Create another circle using the Ellipse Tool (L). This time, set the Width and Height to 1.6 in. On the Swatches panel, set the Fill color to [None] and the Stroke color to [Paper]. Open the Stroke panel (Window > Stroke), and set the Weight to 1 pt.

To align these two objects, open the Align panel. Select both and select the Align Horizontal Center and Align Vertical Center buttons. 

Create two circles using the ellipse tool One with an outline and one solid Use the align panel to align them

Step 2

Duplicate both objects by pressing Shift-Option and dragging. Do this twice to fit a total of three images.

Select each inside circle and press Command-D to Place an image. Add the following images:  

Using the Direct Selection Tool (A), resize each image to fit the circle. Ideally, each person’s head should be the same size.

Duplicate the set of circles twice Place images in each set

Step 3

Using the Text Tool (T), draw a text box under each circle to add names and descriptions. On the Control panel, set the first line’s Font to Config Alt, Font Family to Bold, and Size to 12 pt. 

On the Swatches panel, set the color of the first line to red and the second line to [Paper]. 

Add text to each set of circles

Step 4

Use the Align panel to align the text and images to Horizontal Center. Group each circle object, image and text by selecting them and pressing Command-G. This will make it easier to spread them across the page evenly in the next step.

Group each set of circles with a text box

Step 5

Place the second set of objects in the center of the page. Head over to the Align panel and set the Align to option to Align to Page. Select the Align Horizontal Center button.

Align the second group of objects with the center of the page

Using the Rectangle Tool (M), draw a rectangle to fit from the edge of the page to the left edge of the middle circle. 

Select the rectangle and the first grouped object. On the Align panel, set the Align to option to Align to Selection. Select the Align Horizontal Center button.

Move the rectangle to the right-hand side of the page and repeat the procedure for the last grouped object. When you are done, delete the rectangle. 

Create a rectangle that will help you align the first and third grouping of objects

Step 6

Using the Line Tool (\), draw a line to fit the width of the margin on the bottom of the page. Set the Stroke Weight to 1 pt. Set the stroke color on the Swatches panel to [Paper]. 

Using the Text Tool (T), draw a text box under the line and add contact information. Set the Size to 10 pt and the Tracking to 200.  

I am adding em spaces between the information, followed by a star. Em spaces are larger spaces than a regular space. Add Em spaces by pressing Shift-Command-M. Using the Direct Selection Tool (A), select one of the smaller stars we created. Press Command-C to Copy and Command-V to Paste it between the spaces. Do this as if you were normally copying text in a frame.

Create a line at the bottom of the flyer and using the text tool add contact information

4. How to Export a File for Printing

Before exporting a file for printing, is useful to take a look around the edges of each page. Make sure all the objects that are meant to bleed out of the image are touching the bleeds. 

Step 1

To export the file, go to File > Export. Name the file MLK Event Flyer and choose Adobe PDF (Print) from the Format dropdown menu. Click Save. 

Save the file as an Adobe PDF print file

Step 2

In the Export Adobe PDF window, set the Adobe PDF Preset to Press Quality.

Select Press Quality as a preset

On the left side of the panel, select Marks and Bleeds. Check All Printer’s Marks and Use Document Bleed Settings. Click Export. You will have a ready-to-print PDF file.

Check the Marks and bleeds and document bleed settings options

Great Job! You’ve Finished This Tutorial!

In this tutorial, you learned how to create a ready-to-print promotional event flyer. We looked at key tools to create a template that will be easy to customize with small tweaks. Today, you’ve learned to:

  • create a ready-to-print Adobe InDesign file
  • use the Swatches panel to add color swatches
  • align objects with the Align panel
  • use the different shape tools (ellipse, rectangle, polygon)
  • export a ready-to-print PDF file

If you would like to explore some promotional template ideas, you can find many customizable flyers and brochures over at Envato Elements and Graphic River. Check it out!

If you liked this tutorial, you might like these:

{excerpt}
Read More

Behance Redesigns its Portfolios

There’s been a fairly big update to Behance, also known as DeviantArt for designers. Heck, I remember when I used DA for my portfolio. Good times.

Anyway… Behance. They’ve gone and updated what has to be the single most important aspect of their site: the portfolios. I mean, that’s what everybody is there for, no? They’re overhauled both the main portfolio view, as well as the experience of viewing individual projects in some small but important ways.

Portfolios

Customizable banners: You know those big image banners you get on sites like Twitter and Facebook? Behance has them too, now. Just upload a picture, crop it to your liking, and go. The stated purpose of these is to allow users to sort of set the tone, and get their branding right in there at the top.

Well, that’s the idea on all the other sites with the same feature, really. It’s a tried-and-proven technique. And if you don’t want a banner image, don’t upload one.

Bigger thumbnails: Not much to say, here. They took the old thumbnails, and scaled them right up. People get a better idea of what they’re looking at.

Projects

In their blog post on the update, Behance says, “… actions like Share, Save to Collection, Follow, and Appreciate are always present.” Basically, they kept this part of the UI very simple, and made the action buttons sticky, to reduce the effort it takes to interact with any particular project.

This is a simple but definitely good change. Projects tend to consist of one or more very, very long images, and scrolling can definitely take a while.

My Impressions

The whole experience is definitely tailored for desktop. That’s not to say people don’t look for designers on their phones, but if you really want to see the details, big screens make that easier. Adobe runs this show, so the decision is probably based on a fair amount of data telling them to cater to larger screens.

To be fair, any designer could probably have told them that. We might love our phones, but we work on desktops, laptops, and at the bare minimum, a big ole tablet. In fact, it would be fair to say that Behance is one of the few examples on the Internet where mobile-first design is… I’m going to say almost optional.

Source

How to Use Animation in Angular 6

color animation

In this tutorial, you’ll learn about the importance of animations in improving the user experience. I’ll show you how to incorporate animations in Angular 6 applications with the help of animation components and Bootstrap.

The Role of Animations in User Design

Most web users are visual creatures and therefore respond to visual objects. This means that as a designer, you have to find a way to incorporate animations in your designs.

Animation can prove to be a useful tool when it comes to user interaction with your website or app. However, this doesn’t mean that when you use animation, users will be attracted to your site. You have to strike a balance with the number of animations used at a particular place and time.

Let’s look at some scenarios in which animation can prove useful in user design.

  • Providing Feedback: Animation can be used to acknowledge that a particular action has been received by the system. For example, when a user enters the wrong information, you can use the shake animation to let them know they need to enter their credentials again.
  • Demonstration: Animation can also be used to demonstrate how certain aspects of applications work. This is done by providing visual hints which serve to teach users how the different UI elements operate.
  • Transitions: Transition animation helps the user to keep their focus on the right area. When incorporating transition animations, keep in mind that the process should be smooth and effortless.

Animation States and Transitions

Before we get started on adding animations into our Angular application, let’s first look at the different animation states and transitions available in Angular.

These are the main states in Angular animations:

  • void state: an element which is not in the view is represented by the void state
  • wildcard (*) state: this represents any state

We will look at how these fit in an actual app when we start coding.

In order for an animation to change from one state to another, it needs to transition. The transition event has its own properties, which include:

  • Duration: this property defines the life of an animation. This means from the start of the animation to the time it finishes.
  • Delay: this property is used to define the time between the start of the actual transition and the time it is triggered.
  • Easing: this property controls changes in the speed of an animation. An animation can start out slow and accelerate as it progresses and vice versa.

Setting Up an Angular 6 Project

We will start by initializing a new Angular application as follows:

ng new angularAnimation

The next thing will be to enable animations by importing the BrowserAnimationsModule in app.module.ts as shown below.

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Any animation functions that will be used are then imported from @angular/animations in the component file as follows:

import { trigger, state, style, animate, transition, group } from '@angular/animations';

Define the Animations

Finally, you define all your animations in the components decorator as shown.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'].

 animations: [
    trigger('trigger1', [
        //state and transitions go here

    ]),
    trigger('trigger2', [
        //state and transitions go here
    ]),
    ]

)

The animation property is usually an array that contains one or more triggers as defined above. Each trigger, in addition, has a state and transition functions.

A simple animation property would look like this:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],

  animations: [
  trigger('changeBtnColor', [
    state('state1', style({
      backgroundColor: 'yellow',

    })),
    state('state2', style({
      backgroundColor: 'pink',
      border:'1px solid #18ab29',
      height: '100px',
      width: '200px'
    })),
    transition('state1=>state2', animate('1000ms')),
    transition('state2=>state1', animate('1000ms'))
  ]), ]
})

In the above animation, the name of the trigger is changeBtnColor, and we have two states: state1 and state2. Our element will be yellow in state1, and our animation will change its size and color when transitioning to state2.

Hook an Element to an Animation Trigger

Let’s now hook our element to the trigger in the template as shown below.

<h3>Change color Animation</h3>
<button class ="my_button" (click)="changeState()">Click here</button>
<hr>
<button [@changeBtnColor]=current class ="mybutton" (click)="changeState()">Change Color</button>
<br />

Now go back to the component and define the function that listens to the button click.

export class AppComponent {
  title = 'Animations in Angular';
  current = 'state1';

    changeState() {
      this.current = this.current === 'state1' ? 'state2' : 'state1';
    }
}

Below are the before and after transformations of the animation.

Now that we have mastered the basics of Angular animation, let’s go a little more in-depth with another example. In the next example, we will add animation to list items.

Animating List Items

Now open app.component.ts and update it as follows:

export class AppComponent {
  title = 'Animations';
  mylist = [];
 			
  addElement() {
   this.mylist.push('This list is animated');
  }

  removeElement() {
    this.mylist.length -= 1;
  }
}

Here, we create an empty list and create a function for adding elements to the list and another for removing elements from the list.

Next, we will add the elements that will be applied to the animations. Update the template as follows:

<h3>Enter and Leave animation</h3>
<a (click)="addElement()" href="#" class="myButton">Add List</a>
<a (click)="removeElement()"href="#" class="myButton">Remove List</a>
<div style="width:200px; margin-left: 20px">
  <ul>
    <li *ngFor="let list of mylist">
    {{list}}
    </li>
  </ul>
</div>

We will start adding animations in the component. Open app.component.ts and add the following animations in the component decorator.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],

  animations: [
    trigger('AnimateList', [
      transition(':enter', [  
        style({opacity: 0, transform: 'translateY(-75%)', offset: 1.0}),
        animate('0.2s 600ms ease-in')
      ]),

      transition(':leave', [
        animate('1.2s ease-out', 
        style({opacity: .5, transform: 'translateY(35px)',  offset: 0.3})  
      ]),
    ])
   ]
})

Here we have a trigger called AnimateList which has the :enter and :leave aliases. enter represents the transition from void to * (void => *), while :leave represents the transition from * to void (* => void). During the :enter transition, the animation will wait for 600ms and run for 0.2s. The leave transition will wait for 0.1s and run with no delay.

We now need to update the template to use the animation we have defined above. The list items in app.component.html should look like this:

<div style="width:200px; margin-left: 20px">
  <ul>
    <li *ngFor="let list of mylist" [@AnimateList]>
    {{list}}
    </li>
  </ul>
</div>

The final demo of the application should run as shown below.

Conclusion

This tutorial has covered all that is necessary to get started with your own animations in Angular. For more information, head over to the animations guide and explore the full power of animations in Angular.

Source:: Net Tuts

Try Catch in Swift – A Quick Guide To Basic Error Handling With Try, Try? & Try!

If you’re new to Swift then you’ve likely noticed the three different types of Try statements – try, try! And try?

In order to understand the different try statements we first need to know how to declare errors, Swift provides a nice way for doing this using enums like in this example:

// declare an error
enum CorrectError: Error {
// specific case for error, nice way to create many different errors easily
case Wrong
}

Functions throw errors in Swift by using the throws keyword which is placed before the return arrow (the ->)  like the throwing function in this example:

// simple function that throws error
func isRight() throws -&gt; Bool {
throw CorrectError.Wrong
// return statement never executes
return true
}

In order to utilize a throwing function one of the 3 different try statements.

The try keywords  is used within the do -> catch statement like below, typically you’ll use this when you want to catch different types of errors:

do {
// try isRight function
let answer = try isRight()
// never printed because of thrown error
print("it is right")
} catch CorrectError.Wrong{
// this gets printed because of error
print("Wrong")
}

The try! keyword expects a normal type so  function being executed must not throw any error at all or the program will crash with a fatal error as nil is returned.

// will cause program to crash because of error thrown
let answer = try! isRight()
// never executed because of error
print ("is right")

The try? keyword  returns an optional type so if the function throws an error this value is nil.

// sets answer to nil because of thrown error
let answer = try? isRight()
if answer != nil {
// won’t print because of thrown error
print("is right")
} else {
// prints because of thrown error
print ("Wrong")
}

As you can see Swift provides a nice syntax for handling errors. This is a vast improvement over error handling in the original release of Swift, and in Objective-C.

Original article: Try Catch in Swift – A Quick Guide To Basic Error Handling With Try, Try? & Try!

©2019 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.