Created
November 9, 2014 18:01
-
-
Save regnerjr/561e87e9d7d9af52aba6 to your computer and use it in GitHub Desktop.
A custom PopoverBackgroundView - Which does not work. Errors is EXC_BAD_ACCESS when trying to access the arrowOffset or arrowDirection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// pictPopBGView.swift | |
// | |
import UIKit | |
class pictPopBGView: UIPopoverBackgroundView { | |
override var arrowOffset: CGFloat { | |
get{ | |
return self.arrowOffset | |
} | |
set{ | |
self.arrowOffset = newValue | |
} | |
} | |
override var arrowDirection: UIPopoverArrowDirection { | |
get { | |
return self.arrowDirection | |
} | |
set { | |
self.arrowDirection = newValue | |
} | |
} | |
var arrowView: UIView = UIView(frame: CGRect(origin: CGPoint(x: 0, y: 0), | |
size: CGSize(width: 60, height: 60))) | |
var backgroundView: UIView | |
override init(frame: CGRect) { | |
backgroundView = UIView(frame: frame) | |
backgroundView.backgroundColor = UIColor.purpleColor() | |
arrowView.backgroundColor = UIColor.redColor() | |
super.init(frame:frame) | |
backgroundColor = UIColor.redColor() | |
self.addSubview(arrowView) | |
self.addSubview(backgroundView) | |
} | |
required init(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
func setArrowOffset(offset:CGFloat){ | |
arrowOffset = offset | |
} | |
override class func wantsDefaultContentAppearance() -> Bool { | |
return true | |
} | |
} | |
extension pictPopBGView : UIPopoverBackgroundViewMethods { | |
override class func contentViewInsets() -> UIEdgeInsets { | |
return UIEdgeInsetsZero | |
} | |
override class func arrowBase() -> CGFloat { | |
return 60 | |
} | |
override class func arrowHeight() -> CGFloat { | |
return 60 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment