Objective c XIB视图背景设置为“清晰颜色”,但它不是透明的

Objective c XIB视图背景设置为“清晰颜色”,但它不是透明的,objective-c,xcode,swift,xib,Objective C,Xcode,Swift,Xib,我需要将标题中的背景颜色设置为透明,但它没有设置为透明,我正在使用MAPKit中的自定义对话框pin。怎么了 背景视图颜色设置为“清除颜色” 并通过编程将“颜色”设置为“清晰颜色”: customMarkerXIB.backgroundColor=UIColor.clearColor import UIKit @IBDesignable class Widget: UIView { var view: UIView! var nibName: String = "W

我需要将标题中的背景颜色设置为透明,但它没有设置为透明,我正在使用MAPKit中的自定义对话框pin。怎么了

背景视图颜色设置为“清除颜色”

并通过编程将“颜色”设置为“清晰颜色”:

customMarkerXIB.backgroundColor=UIColor.clearColor

import UIKit





@IBDesignable class Widget: UIView {

    var view: UIView!

    var nibName: String = "Widget"

    @IBOutlet weak var titleLabel: UILabel!

 /*   @IBInspectable var image: UIImage? {
        get {
            return imageView.image
        }
        set(image) {
            imageView.image = image
        }
    }
    */

    @IBInspectable var title: String? {
        get {
            return titleLabel.text
        }
        set(title) {
            titleLabel.text = title
        }
    }



    func setSelectedState(){

        println("hola")

    }

    // init

    override init(frame: CGRect) {
        // properties
        super.init(frame: frame)

        // Set anything that uses the view or visible bounds
        setup()
    }

    required init(coder aDecoder: NSCoder) {
        // properties
        super.init(coder: aDecoder)

        // Setup
        setup()
    }

    func setup() {
        view = loadViewFromNib()

        view.frame = bounds
        view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight

        addSubview(view)
    }

    func loadViewFromNib() -> UIView {

        let bundle = NSBundle(forClass: self.dynamicType)
        let nib = UINib(nibName: nibName, bundle: bundle)
        let view = nib.instantiateWithOwner(self, options: nil)[0] as UIView

        return view
    }





    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
    }
    */

}
加载自定义注释

 func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
        var identifier = "CustomAnnotation"
        var position = 0;
        if let mapPin = annotation as? MyAnnotation {
            position = mapPin.position; // assosiate annotation with a position
        }

        if annotation.isKindOfClass(MyAnnotation) {
            var marker =  mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)

            if marker == nil {
                marker = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)
                marker.tag = position;
                marker.image = UIImage(named: "mapa_pin")
                marker.centerOffset = CGPointMake(0, -10)
                marker.canShowCallout = true
                marker.backgroundColor = UIColor.clearColor()

                //var pointTitle = marker!.annotation.title! as String


           /*     var label:UILabel = UILabel(frame: CGRectMake(0, CGFloat(floorf((56.0-20)/2)), 26.0, 20))
                label.backgroundColor = UIColor.clearColor()
                label.text = "asdfasdfasdfasd"
                label.textAlignment = NSTextAlignment.Center
                label.font = UIFont.systemFontOfSize(11.0)
                marker.addSubview(label) */



                var customMarkerXIB : Widget = Widget(frame: CGRect(x: 0, y: 250, width: 300, height: 150))
                customMarkerXIB.backgroundColor = UIColor.clearColor()

                customMarkerXIB.title = "olakease";
                customMarkerXIB.setSelectedState()


                marker.rightCalloutAccessoryView = customMarkerXIB

                // Callout
            /*    var button = UIButton.buttonWithType(.DetailDisclosure) as UIButton
                marker!.leftCalloutAccessoryView = button

                var image = UIImageView(image: UIImage(named: "mapa_pin"))
                marker!.rightCalloutAccessoryView = image*/


            } else {
                marker!.annotation = annotation
            }

            return marker
        }

你能分享你的代码吗?试着切换“不透明”属性!!我将不透明设置为0。。。于是,景色消失了