Hey jowi,
The easiest solution I can think of is to extend an UIView and override the
TouchesBegan and TouchesEnded methods. Using UIButton (and their Touch*
events) is for buttons with text only AFAIK. So, here's what you do:
public class RemoteControlButton : UIView {
public RemoteControlButton(UIImage up, UIImage down) : base() {
AddSubview(new UIImageView(up));
AddSubview(new UIImageView(down));
// Assume both images are the same size:
Frame = new RectangleF(new PointF(0, 0), up.Size);
}
public override void TouchesBegan(NSSet touches, UIEvent evt) {
base.TouchesBegan(touches, evt);
ExchangeSubview(0, 1);
}
public override void TouchesEnded(NSSet touches, UIEvent evt) {
base.TouchesEnded(touches, evt);
ExchangeSubview(0, 1);
}
}
And then add it to your UIView or UIViewController (override ViewDidLoad)
like this:
View.AddSubview(new RemoteControlButton(UIImage.FromFile("PATH1"),
UIImage.FromFile("PATH2")));
And to answer you second question; Give http://iconfinder.com a go.
Hope this helps.
Mikkel
On Fri, Sep 30, 2011 at 18:57, jowi <[email protected]> wrote:
> This is a question in 2 parts ;) first, i'm wondering what the best method
> is
> for creating the effect of a button on screen that is being pushed when
> clicked/touched, like a button on a fysical remote control. My guess is i
> need 2 different images, one for each state. But how to go from there? Do i
> write some code on the TouchInside handler or is there a specific method to
> attach a button to a specific button state?
>
> Furthermore, how do i actually create nice buttons? I've experimented a bit
> with photoshop to create rounded buttons with a bevel etc. but since i'm no
> photoshop guru, the result is just not what i want... anybody got a link to
> a nice workshop or walkthrough on how to create some good buttons, both for
> normal and pushed state? Or an online library with all sorts of buttons?
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/How-to-create-buttons-that-can-be-pushed-tp3860429p3860429.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch