AMSlideMenu deepness effect for the menus - ios

im working with AMSlideMenu, and i did in the MainVC
// Enabling Deepnes on left menu
- (BOOL)deepnessForLeftMenu
{
return YES;
}
// Enabling Deepnes on right menu
- (BOOL)deepnessForRightMenu
{
return YES;
}
Normally a deepness effect will be in the left and right menu, but nothing happen .
Did anyone tried AMSlideMenu before and had same pb ?

Yes it is working. You just need to observe it. If -deepnessForLeftMenu is enabled you can see that menu will be transform and it shows animation and scaling of left menu.
Put a debugger check in AMSlideMenuMainViewController.m class for below method and you will see the differences.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Put a break point here.
if (self.leftMenu && [self deepnessForLeftMenu])
{
self.leftMenu.view.layer.transform = kMenuTransformScale;
self.leftMenu.view.layer.opacity = kMenuLayerInitialOpacity;
}
if (self.rightMenu && [self deepnessForRightMenu])
{
self.rightMenu.view.layer.transform = kMenuTransformScale;
self.rightMenu.view.layer.opacity = kMenuLayerInitialOpacity;
}
}
Also the deepnessForLeftMenu bool variable used in other two methods for the same class
- (void)configure3DTransformForMenu:(AMSlideMenu)menu panningView:(UIView *)panningView
{
float cx = 0;
float cy = 0;
float cz = 0;
float opacity = 0;
// Put a break point here.
/********************************************* DEEPNESS EFFECT *******************************************************/
if (menu == AMSlideMenuLeft && panningView.frame.origin.x != 0 && [self deepnessForLeftMenu])
{
// Codes for deepness effect
}
}
If you set NO for deepnessForLeftMenu variable. You will able to see that menu will show flat animation.

Related

Can't drag or move custom NSWindow

I create a NSWindowController and NSViewController using Interface Builder, And then, i removed the NSWindow's titlebar so that I can custom Window. i create a class subclass NSWindow And do following things in class.
override var canBecomeKey: Bool {
return true
}
override var canBecomeMain: Bool {
return true
}
i also set these in NSWindowController:
{
self.window?.becomeKey()
self.window?.isMovableByWindowBackground = true
self.window?.isMovable = true;
self.window?.acceptsMouseMovedEvents = true
}
from here, the custom Window is can be dragged,
But when i make the NSViewController as the NSWindowController's ContentViewController, i can not drag the customWindow.
What could be happening here?
I had this problem before, here was my solution that works (it's in objective-C though, so just throwing it out there in case it helps):
#property BOOL mouseDownInTitle;
- (void)mouseDown:(NSEvent *)theEvent
{
self.initialLocation = [theEvent locationInWindow];
NSRect windowFrame = [self frame];
NSRect titleFrame = NSMakeRect(0, windowFrame.size.height-40, windowFrame.size.width, 40);
NSPoint currentLocation = [theEvent locationInWindow];
if(NSPointInRect(currentLocation, titleFrame))
{
self.mouseDownInTitle = YES;
}
}
- (void)mouseDragged:(NSEvent *)theEvent
{
if( self.mouseDownInTitle )
{
NSRect screenVisibleFrame = [[NSScreen mainScreen] visibleFrame];
NSRect windowFrame = [self frame];
NSPoint newOrigin = windowFrame.origin;
NSPoint currentLocation = [theEvent locationInWindow];
// Update the origin with the difference between the new mouse location and the old mouse location.
newOrigin.x += (currentLocation.x - self.initialLocation.x);
newOrigin.y += (currentLocation.y - self.initialLocation.y);
// Don't let window get dragged up under the menu bar
if ((newOrigin.y + windowFrame.size.height) > (screenVisibleFrame.origin.y + screenVisibleFrame.size.height)) {
newOrigin.y = screenVisibleFrame.origin.y + (screenVisibleFrame.size.height - windowFrame.size.height);
}
[self setFrameOrigin:newOrigin];
}
}
The controlling factor here is the view's mouseDownCanMoveWindow property. By default that depends, in turn, on its isOpaque property. If you or one of your superclasses override isOpaque to return true, then the default implementation of mouseDownCanMoveWindow will return false. If you want it to behave differently, then you have to override that, too.

Touches turn on and off light

I'm trying to set alpha of a SKNode every time it is clicked either to 0 or 1. My code currently turns it off but won't turn it back on. Any idea why?
- (void)handleTouchedPoint:(CGPoint)touchedPoint {
touchedNode = [self nodeAtPoint:touchedPoint];
// Detects which node was touched by utilizing names.
if ([touchedNode.name isEqualToString:#"play"]) {
isOnPlay = true;
NSLog(#"Touched play");
}
if ([touchedNode.name isEqualToString:#"light1"]) {
//NSLog(#"%.2f", touchedNode.alpha);
if(touchedNode.alpha != 0.0)
{
NSLog(#"Off");
touchedNode.alpha = 0.0;
//[touchedNode setAlpha:0.0];
}
else{
NSLog(#"On");
touchedNode.alpha = 1.0;
//[touchedNode setAlpha:1.0];
}
NSLog(#"Touched light");
}
}
You might be running into the famous float rounding issue. Use debug and check the values. The alpha might not be exactly zero.

Disable right bar button when selected equals 0

The below code for the most part works when selecting items, the bar button enables, but as soon as I unselect 1 with say 3 still selected, it disables.
How can I use the below code to disable when the count reaches 0 items selected?
- (void)assetsTableViewCell:(WSAssetsTableViewCell *)cell didSelectAsset:(BOOL)selected atColumn:(NSUInteger)column
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
// Calculate the index of the corresponding asset.
NSUInteger assetIndex = indexPath.row * self.assetsPerRow + column;
WSAssetWrapper *assetWrapper = [self.fetchedAssets objectAtIndex:assetIndex];
assetWrapper.selected = selected;
// Update the state object's selectedAssets.
[self.assetPickerState changeSelectionState:selected forAsset:assetWrapper.asset];
// Update navigation bar with selected count and limit variables
dispatch_async(dispatch_get_main_queue(), ^{
if (self.assetPickerState.selectionLimit) {
self.navigationItem.title = [NSString stringWithFormat:#"%# (%lu/%ld)", [self.assetsGroup valueForProperty:ALAssetsGroupPropertyName], (unsigned long)self.assetPickerState.selectedCount, (long)self.assetPickerState.selectionLimit];
}
});
}
Below is what needs adjusting.
if (selected == 1) {
self.navigationItem.rightBarButtonItem.enabled = YES;
} else if (selected == 0) {
self.navigationItem.rightBarButtonItem.enabled = NO;
}
selected will give you the state of the current asset so it wouldn't be wise to check this.
We need to check for some kinda global thing; basically to check for previous selections.
Looking at your navigationItem.title, it seems assetPickerState.selectedCount should do the trick.
So... maybe this?? (not sure but anyways...)
if (self.assetPickerState.selectedCount == 0) {
self.navigationItem.rightBarButtonItem.enabled = NO;
}
else {
self.navigationItem.rightBarButtonItem.enabled = YES;
}
Looks like you're only explicitly enabling the button when you have 1 selected (not more than that). Just going out on a whim but this might work (only disable if zero, otherwise enable it).
if (selected == 0) {
self.navigationItem.rightBarButtonItem.enabled = NO;
} else {
self.navigationItem.rightBarButtonItem.enabled = YES;
}

Cocos2d - CCLabelTTF overlays new value when updated

I have a CCLabelTTF variable defined as follows
#implementation LevelScene
{
CCLabelTTF *_collectedLabel;
int collectedStars1;
int collectedStars2;
int collectedStars3;
}
I also have a CCScrollView and I listen for scrollViewDidScroll.
- (void)setPageIndicatorTo:(NSInteger)page
{
if (page == 0) {
_collectedLabel.string = [NSString stringWithFormat:#"%d/75", collectedStars1];
} else if (page == 1) {
_collectedLabel.string = [NSString stringWithFormat:#"%d/75", collectedStars2];
} else if (page == 2) {
_collectedLabel.string = [NSString stringWithFormat:#"%d/75", collectedStars3];
}
}
- (void)scrollViewDidScroll:(CCScrollView *)scrollView
{
[self setPageIndicatorTo:_scrollView.horizontalPage];
}
In didLoadFromCCB, I set _collectedLabel.string to some value. It gives me the following :
When the view scroll, it calls - (void)setPageIndicatorTo:(NSInteger)page and thus updates the string. I then get
It should be 0/75. The new label overlays the previous one... How can I force the string to be updated?
I tried setting the string to "" before setting it to another value, but it gave the same result..

How to animate transition from one state to another for UIControl/UIButton? [duplicate]

This question already has an answer here:
Fading out an UIButton when touched
(1 answer)
Closed 9 years ago.
I have a UIButton that changes image on highlight. When transitioning from UIControlStateHighlight to UIControlStateNormal, I want the highlighted image to slowly fade back into the normal image. Is there an easy way to do this?
I ended up subclassing UIButton. Here's the implementation file code. I took some app-specific stuff out, so I haven't tested this exact code, but it should be fine:
#import "SlowFadeButton.h"
#interface SlowFadeButton ()
#property(strong, nonatomic)UIImageView *glowOverlayImgView; // Used to overlay glowing animal image and fade out
#end
#implementation SlowFadeButton
-(id)initWithFrame:(CGRect)theFrame mainImg:(UIImage*)theMainImg highlightImg:(UIImage*)theHighlightImg
{
if((self = [SlowFadeButton buttonWithType:UIButtonTypeCustom])) {
self.frame = theFrame;
if(!theMainImg) {
NSLog(#"Problem loading the main image\n");
}
else if(!theHighlightImg) {
NSLog(#"Problem loading the highlight image\n");
}
[self setImage:theMainImg forState:UIControlStateNormal];
self.glowOverlayImgView = [[UIImageView alloc] initWithImage:theHighlightImg];
self.glowOverlayImgView.frame = self.imageView.frame;
self.glowOverlayImgView.bounds = self.imageView.bounds;
self.adjustsImageWhenHighlighted = NO;
}
return self;
}
-(void)setHighlighted:(BOOL)highlighted
{
// Check if button is going from not highlighted to highlighted
if(![self isHighlighted] && highlighted) {
self.glowOverlayImgView.alpha = 1;
[self addSubview:self.glowOverlayImgView];
}
// Check if button is going from highlighted to not highlighted
else if([self isHighlighted] && !highlighted) {
[UIView animateWithDuration:1.0f
animations:^{
self.glowOverlayImgView.alpha = 0;
}
completion:NULL];
}
[super setHighlighted:highlighted];
}
-(void)setGlowOverlayImgView:(UIImageView *)glowOverlayImgView
{
if(glowOverlayImgView != _glowOverlayImgView) {
_glowOverlayImgView = glowOverlayImgView;
}
self.glowOverlayImgView.alpha = 0;
}
#end
You could also just pull the highlighted image from [self imageForState:UIControlStateHighlighted] and use that, it should work the same. The main things are to make sure adjustsImageWhenHighlighted = NO, and then overriding the setHighlighted: method.

Resources