The easiest ways to paint your burglar bars is either with a brush, small roller or using a lamb's wool mitt. Spraying will be very problematic, especially the overspray. The mitt or roller will be the fastest but the ends still needs to be cut in.
You have two options; paint the trim first then tape around the ends of the bars with blue tape or paint the bars first and cut around them when painting the trim. I think it's easier to paint the trim first.
Use the roller or mitt, what ever is easier for you, and then brush the ends. Allow to dry then paint the trim.