This is somewhat dependent on the type of UVB you are using, the density of your plants and the mesh at the top of your enclosure, but generally speaking, your cham needs to be able to get within 12 inches of your UVB bulb.
As for basking, it depends on the strength of the bulb. Obviously, a chameleon needs to be closer to a 40 watt bulb than a 100 watt bulb to get the right temperature. So, it depends on your bulb. You need to make sure the basking spot hits the right temperature and adjust your bulb strength and/or distance accordingly. You also want to make sure your cham can't get close enough to the basking light, either from another branch or climbing the screen, etc. to burn themselves.