It depends on what you want the black coating to accomplish. Different solutions will work better or worse depending on your needs, and goals. Here's a few off the top of my head:
Anodizing forms a hardened protective barrier on the part. it's actually rust - Aluminum oxide that's force grown on the surface. Aluminum oxide is a clear crystal that is nearly as hard as a diamond, giving a nice durable finish to the surface. the Color is just a Dye that gets trapped between the crystals. it's below the surface and doesn't scratch off easy. But Anodized dyes often break down in UV light, so the color can fade over time in sunlight.
Powder coating adds a thin layer of polymer resin that is baked onto the surface. it's very durable and doesn't scratch or flake off like paint can. Being a plastic, it doesn't keep it's gloss for more than a couple years when exposed to direct sun, and will lose gloss over time regardless. non gloss coats tend to last much longer, but either can be durable protectants for decades.
Automotive grade paints are thick, 2 part paints that are designed to hold up to sun and weather for many years. Of the 3 listed, this will give you the deepest, glossiest black finish. With care, the finish will last decades. They are fairly chip resistant but not as scratch resistant as Anodizing and powder coating. They are also expensive.
Plasti-dip. This is a liquid plastic coating. you can dip parts in, or spray on from a rattle can. the finish is plasticy looking and a bit rubbery, but it's fairly durable. it's also not overly hard to peel off and do over if you want. it will hold up a couple years.
Spray paint. Good spray paint can hold up for many years and look almost as good as automotive paint. It will scratch fairly easy and tends to chip and flake off of un-primered surfaces.
POR-15. This is a brush on or dip in type of paint. (avoid the spray paint version) It's more of a polymer coating than a true paint, and will form a hard protective barrier. It's an industrial black color, so you aren't going to get the deep gloss and rich black color of automotive paint, but it's meant for coating machine parts to prevent rust in dirty, harsh environments.
Truck Bed Liner is a brush on or spray on polymer. it forms a thick, rough textured finish that will stand up to just about anything. The surface takes on a black textured rubber look over time. it's extremely durable and hides many imperfections.