The "greenhouse effect" of the atmosphere is named by analogy to greenhouses which become warmer in sunlight. However, a greenhouse is not primarily warmed by the "greenhouse effect". "Greenhouse effect" is actually a misnomer since heating in the usual greenhouse is due to the reduction of convection, while the "greenhouse effect" works by preventing absorbed heat from leaving the structure through radiative transfer.
Earth receives energy from the Sun in the form of ultraviolet, visible, and near-infrared radiation. About 26% of the incoming solar energy is reflected to space by the atmosphere and clouds, and 19% is absorbed by the atmosphere and clouds. Most of the remaining energy is absorbed at the surface of Earth. Because the Earth's surface is colder than the Sun, it radiates at wavelengths that are much longer than the wavelengths that were absorbed. Most of this thermal radiation is absorbed by the atmosphere and warms it.
Earth's surface, warmed to a temperature around 255 K, radiates long-wavelength, infrared heat in the range of 4–100 μm.
Greenhouse gases—including most diatomic gases with two different atoms (such as carbon monoxide, CO) and all gases with three or more atoms—are able to absorb and emit infrared radiation. Though more than 99% of the dry atmosphere is IR transparent (because the main constituents—N2, O2, and Ar—are not able to directly absorb or emit infrared radiation)
So, you see, the earth absorbs the uv rays and re-emits them as infrared ("at wavelengths that are much longer than the wavelengths that were absorbed"), which in turn warms up the atmosphere
So sadly both things you said are incorrect: Neither greenhouses nor greenhouse gases have anything to do with trapping uv rays; if they did, they would block them, too, which would be pointless for a greenhouse
Consider this: While skiing, you can get a tan even in winter, because snow is white and therefore reflects light instead of absorbing it; that's also why snow seems so bright in direct sunlight. But most of the world's surface isn't white , it warms up instead of reflecting light, re-emitting the heat as ir radiation (among other forms of heat dissipation, of course)