I might’ve solved this. My overlay view works now because I draw based on the
overlay view’s frame, NOT based on the rect that gets passed in to drawRect().
I must not understand what that parameter is for.
I guess the pinning constraints were working all along, but I just couldn’t
tell because my circle kept being drawn in the wrong place.
Does it look like I’m doing this the right way now, or am I heading for trouble
by ignoring the parameter to drawRect()?
class CircleOverlayView: UIView {
override init( frame: CGRect )
{
super.init( frame: frame )
opaque = false
userInteractionEnabled = false
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = UIColor.clearColor()
}
required init?( coder: NSCoder )
{
super.init( coder: coder )
}
override func drawRect( rect: CGRect )
{
let w = frame.size.width
let h = frame.size.height
let d = min( w, h )
let innerRect = CGRectMake( ( w - d ) / 2, ( h - d ) / 2, d, d )
let innerPath = UIBezierPath( ovalInRect: innerRect )
UIColor.redColor().setStroke()
innerPath.lineWidth = 2
innerPath.stroke()
}
}
--
Charles
On February 23, 2016 at 3:49:28 PM, Quincey Morris
([email protected]) wrote:
On Feb 23, 2016, at 12:32 , Charles Jenkins <[email protected]> wrote:
This is the first time I’ve tried to inject an overlay view into the view
hierarchy, so I’m probably doing it completely wrong or missing something very
basic.
I’d suggest you go and watch the WWDC videos about advanced scroll view usage,
starting with session 104 in 2011, then session 223 in 2012, session 217 in
2013 and session 235 in 2014. Unfortunately, that’s where the series seems to
have ended.
That’s a bit under 4 hours of video, but they’re incredibly well worth watching
for anyone who’s interested in doing clever things with scroll views. Not only
are they technically enlightening, but they are very, very entertaining.
There’s 5 minutes or so in one of these videos that will tell you how to solve
your problem neatly. (Bu I don’t know *which* 5 minutes. Possibly the “moon
over cityscape” section?) The rest is just for fun.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]