iOSLib & iOSKit!

Jason and I are pleased to announce that it looks like both our libraries have become friends finally. This doesn’t mean they are merged – we both follow different design schemes –, but the first iOS app containing both libraries in unmodified form is soon under review by Apple.

So no need to decide for one library anymore and the possibility to use both their features in a single project. If you have to convert between their objects, the constructors take the ptr – which is named Id in iOSLib and Handle in iOSKit. iOSKit offers an implicit conversion to its pointer, iOSLib objects feature a class.makeFromPtr shared constructor method that returns NIL instead of an “empty” instance structure.

Please let us know if you encounter any problems!

Ulrich thanks again for all your work on this.

I’m using your DrawLinearGradient iOSGraphics extension to improve the “widgets” in my app’s dashboard and they look really good. However, previously I was using FillRoundRect to draw a rectangle with slightly rounded corners. Is there a way to draw a linear gradient with rounded corners?

Could you use iOSGraphics.ClipToPath to mask the area that you are filling with gradient? iOSPath includes iOSPath.AddRoundRect that could easily get you the rounded corner that you are looking for.

Great news, Ulrich and Jason!

You guys rock. Thank you so much for all the hard work!

Sorry for a wrong information – here’s what Jason wrote:

And thanks a lot, you all!

@Jason Tait, I removed the private CGContext Get…methods and hope that was all that stopped the app from admission to the app store.

This could work. You can even stay on CGContext level: I have added the clip methods to CGContext now. Please test and tell me if they’re ok.

Clip(): Sets the clipping path to the current path ClipEO(): The same, but with alternative fill rules ClipToMask (Mask as iOSImage / AppleCGImage): Sets the clipping to the shape of an image ClipToRect (Rect As Xojo.Core.Rect / FoundationFramework.NSRect / x,y,w,h as double): Clips to a rectangle ClipToRects (Rects() as Xojo.core.Rect / AppleArray of NSRect): Clips to a multitude of rectangles. ClipBoundingBox As Xojo.Core.Rect / FoundationFrameWork.NSRect (read-only): Gives you the dimensions of the clipping rectangle.

Additionally, I will upload a new version soon that features all features of UIBezierPath. Sadly, you cannot convert from an iOSPath currently because it has no handle. I hope the engineers will allow access to more classes in a later revision.

And I added a short teaser in the splash screen: UIDynamics will be next.

Thanks a lot guys for your work!!!

You’re very welcome!
As an addition to the clipping question: Yes, it works the way Scott proposed. If you want to stay on CGContext level, the (now tested) alternative would be (this is the paint event of a canvas showing a gradient with rounded corners):

Sub Paint(g As iOSGraphics) g.AddPath new AppleCGPathRoundedRect (FoundationFrameWork.nsmakerect (0,0,g.Width,g.Height), 2, 2) g.clip g.DrawLinearGradient array(&c394D7E00, &cDA770000, &c7478FF00), 0,0,g.Width, g.Height End Sub

P.S.: UIDynamics is amazing! You can add physics simulations to any control you like, like here for an ImageView:
AppleDynamics

No need for SpriteKit or whatever setup.

The code is only

[code] static Animator as new AppleDynamicAnimator (self)
dim gravity as new AppleGravityBehavior (ImageView1)
gravity.AngleInDegrees =90

dim collision as new AppleCollisionBehavior (ImageView1)
collision.TranslatesReferenceBoundsIntoBoundary = true
collision.AddBoundary (“barrier”, new AppleBezierPath(Canvas1.AppleView.Frame))
collision.CollisionBehavior = AppleCollisionBehavior.UICollisionBehaviorMode.Everything

dim Behavior as new AppleDynamicItemBehavior (ImageView1)
Behavior.Elasticity = 0.9
animator.AddBehavior gravity
animator.AddBehavior collision
Animator.AddBehavior Behavior[/code]

I’m just fiddling out an easy-to-use Collision Delegate object, the rest is as good as finished.